Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Class Member Declaration Problem

Class Member Declaration Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicstutoriallearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    all_in_flames
    wrote on last edited by
    #1

    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!

    D M 2 Replies Last reply
    0
    • A all_in_flames

      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!

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      all_in_flames wrote:

      students.cpp(62) : error C2065: 'GradeList' : undeclared identifier

      Because GradeList() is not a member of class Student.


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      1 Reply Last reply
      0
      • A all_in_flames

        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!

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        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?

        A 1 Reply Last reply
        0
        • M Michael Dunn

          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?

          A Offline
          A Offline
          all_in_flames
          wrote on last edited by
          #4

          You are a C++ gawd. Thanks again Mike!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups