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