Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > Virtual functio...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4286 of 4370
Post > Topic >>

Virtual function

by "deelBlue" <deel007@[EMAIL PROTECTED] > Sep 25, 2008 at 04:11 AM

Hi all,
I am learning C++ and have some trouble to code a little exampl.e
it 's look like
//Parent.h
#ifndef _PARENT_H
#define _PARENT_H
class Parent
{
public:
	int virtual get_id();
	void virtual set_id(int id);

};
#endif

//Child1.h
#ifndef _CHILD1_H
#define _CHILD1_H
#include "Parent.h"
class Child1: public Parent
{
	private:
	int id;


};
#endif
//Child1.cpp
#include "Child1.h"
int  get_id()
{
	return Child1::id;
};
void  set_id(int id)
{
	Child1::id=id;
};

and I get this error " child1.cpp(4) Invalid reference to non-static
members 
'Child1::id"

could some help me?

thanks
 




 3 Posts in Topic:
Virtual function
"deelBlue" <  2008-09-25 04:11:46 
Re: Virtual function
asm23 <asmwarrior@[EMA  2008-09-25 11:12:19 
Re: Virtual function
Bart van Ingen Schenau &l  2008-09-25 19:16:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 16:22:32 CST 2008.