Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem inheriting

Status
Not open for further replies.

javaguy1

Programmer
Joined
May 14, 2003
Messages
136
Location
US
i have a protected member variable (actually i made it public but the code still doesnt compile) in my base class header file

vector<string> vocabulary;

i create derived classes

#include &quot;Person.h&quot;
class FemalePerson : public Person

derived classes have a private function

void createVocabulary();

the compiler gives an unknown identifier error for the variable vocabulary when it encounters it in
createVocabulary()
 
This compiles without errors (VC7 WinXP Professional)
Code:
class Person{
protected:
	vector<string> vocabulary;
};
class Female : public Person{
private:
	void createVocabulary();
};
void Female::createVocabulary(){
	vocabulary.push_back(&quot;hello&quot;);
}

-pete
 
thanks, in my cpp file i had
void createVocabulary()
instead of
void FemalePerson::createVocabulary()
d'oh! i knew i needed to stop reading and write some code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top