/*
Dev-C++ 4.9.9.2
Will someone be so kind as to explain why I get
these errors at compile time:
line 30: variable or field 'opendoor' declared void
line 30: 'int person:pendoor' is not a static member of 'class person'
line 30: 'house' was not declared in this scope
line 30: 'h' was not declared in this scope
line 51: 'class person' has no member named 'opendoor'
*/
#include <iostream>
using namespace std;
class door
{
public:
door(){lock=true;}
void setlock(bool l){lock=l;}
private:
bool lock;
};
class person
{
public:
person(){}
void opendoor(house * h);
};
void person:pendoor(house * h)
{
bool l=false;
h->getd()->setlock(l);
}
class house
{
friend class person;
public:
house(){p=new person; d=new door;}
door* getd(){return d;}
person* getp(){return p;}
private:
person * p;
door * d;
};
int main()
{
house * h = NULL;
h = new house;
h->getp()->opendoor(h);
return 0;
}
Dev-C++ 4.9.9.2
Will someone be so kind as to explain why I get
these errors at compile time:
line 30: variable or field 'opendoor' declared void
line 30: 'int person:pendoor' is not a static member of 'class person'
line 30: 'house' was not declared in this scope
line 30: 'h' was not declared in this scope
line 51: 'class person' has no member named 'opendoor'
*/
#include <iostream>
using namespace std;
class door
{
public:
door(){lock=true;}
void setlock(bool l){lock=l;}
private:
bool lock;
};
class person
{
public:
person(){}
void opendoor(house * h);
};
void person:pendoor(house * h)
{
bool l=false;
h->getd()->setlock(l);
}
class house
{
friend class person;
public:
house(){p=new person; d=new door;}
door* getd(){return d;}
person* getp(){return p;}
private:
person * p;
door * d;
};
int main()
{
house * h = NULL;
h = new house;
h->getp()->opendoor(h);
return 0;
}