Results 1 to 3 of 3

Thread: Undeclared Identifier in class that is declared private?

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Undeclared Identifier in class that is declared private?

    Hey guys I have a class called validID. its broken up into validID.h and validID.cpp.

    In validID.h I declare int id as private.

    and in validID.cpp I try to set a value to id, but I get a compile error saying it is undeclared....

    Here is my code, can you see what I'm doing wrong?

    Thanks!

    PHP Code:
    //validID.h

    #ifndef VALIDID_H
    #define VALIDID_H

    class validID {


    public:
        
    validID(int 0);  //default constructor


        
    int getID() const; //return ID number
        
    void setID(int);   //set ID number


    private:
        
    int id//id number

    }; //end class validID

    #endif

    //-----------------------------------------------------------------

    //validID.cpp

    #include <iostream>

    using std::cin;
    using std::cout;
    using std::endl;

    #include "validID.h"

    #include "errorHandler.h"



    validID::validID(int idNum)
    {
        
    }
    // end constructor


    void setID(int idNum)
    {

    if(
    idNum || idNum 10000)
        {
            throw 
    errorHandler();

        }else{ 

           
    id idNum//here is where the error is coming from

        
    }// end if

    }// end setID 
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Undeclared Identifier in class that is declared private?

    You missed the validID:: before the setID member function.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    Re: Undeclared Identifier in class that is declared private?

    That was it, thanks alot!
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width