|
-
May 11th, 2005, 03:48 PM
#1
Thread Starter
PowerPoster
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 < 1 || 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.

-
May 11th, 2005, 03:53 PM
#2
Not NoteMe
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. 
-
May 11th, 2005, 04:39 PM
#3
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|