Class Member Declaration Problem
-
Hi everyone, I am working on a project for a C++ course, and I am running into a compile error that I can't figure out how to fix. It seems to be telling me that I am using a class member that is an undeclared identifier. As far as I can tell, it has been declared. Here is the class declaration: class Student { public: /* Constructors and Destructor */ Student(); virtual ~Student(); Student(std::string first, std::string last, int SNum); /* Getters and Setters */ std::string getFirstName(void); void setFirstName(std::string newName); std::string getLastName(void); void setLastName(std::string newName); int getStudentNum(void); void setStudentNum(int newNum); std::vector getGradeList(void); void setGradeList(std::vector &GList); private: std::string FirstName; std::string LastName; int StudentNum; std::vector GradeList; }; And this is the code that is giving the problems at compile-time: void setGradeList(std::vector &GList) { GradeList = GList; } Build error: students.cpp(62) : error C2065: 'GradeList' : undeclared identifier So, this is driving me crazy, and any help would be greatly appreciated! Thanks in advance!
-
Hi everyone, I am working on a project for a C++ course, and I am running into a compile error that I can't figure out how to fix. It seems to be telling me that I am using a class member that is an undeclared identifier. As far as I can tell, it has been declared. Here is the class declaration: class Student { public: /* Constructors and Destructor */ Student(); virtual ~Student(); Student(std::string first, std::string last, int SNum); /* Getters and Setters */ std::string getFirstName(void); void setFirstName(std::string newName); std::string getLastName(void); void setLastName(std::string newName); int getStudentNum(void); void setStudentNum(int newNum); std::vector getGradeList(void); void setGradeList(std::vector &GList); private: std::string FirstName; std::string LastName; int StudentNum; std::vector GradeList; }; And this is the code that is giving the problems at compile-time: void setGradeList(std::vector &GList) { GradeList = GList; } Build error: students.cpp(62) : error C2065: 'GradeList' : undeclared identifier So, this is driving me crazy, and any help would be greatly appreciated! Thanks in advance!
all_in_flames wrote:
students.cpp(62) : error C2065: 'GradeList' : undeclared identifier
Because
GradeList()
is not a member of classStudent
.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Hi everyone, I am working on a project for a C++ course, and I am running into a compile error that I can't figure out how to fix. It seems to be telling me that I am using a class member that is an undeclared identifier. As far as I can tell, it has been declared. Here is the class declaration: class Student { public: /* Constructors and Destructor */ Student(); virtual ~Student(); Student(std::string first, std::string last, int SNum); /* Getters and Setters */ std::string getFirstName(void); void setFirstName(std::string newName); std::string getLastName(void); void setLastName(std::string newName); int getStudentNum(void); void setStudentNum(int newNum); std::vector getGradeList(void); void setGradeList(std::vector &GList); private: std::string FirstName; std::string LastName; int StudentNum; std::vector GradeList; }; And this is the code that is giving the problems at compile-time: void setGradeList(std::vector &GList) { GradeList = GList; } Build error: students.cpp(62) : error C2065: 'GradeList' : undeclared identifier So, this is driving me crazy, and any help would be greatly appreciated! Thanks in advance!
You left out the class name in the function header:
void Student::setGradeList(std::vectorstd::string& GList)
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
You left out the class name in the function header:
void Student::setGradeList(std::vectorstd::string& GList)
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
You are a C++ gawd. Thanks again Mike!