Hej
Czy ktoś może mi wytlumaczyć w czym jest problem ?
Hen.h
#include <iostream>
#include <string>
class Nest;
class Hen
{
public:
void display(Nest *ptr);
void set(Nest *ptr, int i, int j);
class Nest
{
int nest_i, nest_j;
public:
friend class Hen;
void display();
class Egg
{
int egg_i, egg_j;
public:
void display();
};
};
};
Hen.cpp
#include "Hen.h"
using namespace std;
void Hen::display(Nest *ptr)
{
// cout << "Hen display called ! " << endl;
// cout << "i " << ptr->nest_i << " j " << ptr->nest_j << endl;
}
void Hen::set(Nest *ptr, int i, int j)
{
// ptr->nest_i = i;
// ptr->nest_j = j;
}
void Hen::Nest::display()
{
cout << "Nest display called ! " << endl;
}
void Hen::Nest::Egg::display()
{
cout << "Egg display called ! " << endl;
}
main.cpp
#include "klasa.h"
#include "Hen.h"
#include "conio.h"
using namespace std;
int main()
{
Hen hen;
Hen::Nest nest;
Hen::Nest::Egg egg;
//hen.display(&nest);
nest.display();
egg.display();
_getch();
return 0;
}
przy probie kompilacji dostaje takie oto dwa bledy :
1>f:\programy\microsoft visual c++ 2008\projects\cwiczenie 1\cwiczenie 1\hen.cpp(6) : error C2511: 'void Hen::display(Hen::Nest *)' : overloaded member function not found in 'Hen'
1> f:\programy\microsoft visual c++ 2008\projects\cwiczenie 1\cwiczenie 1\hen.h(7) : see declaration of 'Hen'
1>f:\programy\microsoft visual c++ 2008\projects\cwiczenie 1\cwiczenie 1\hen.cpp(12) : error C2511: 'void Hen::set(Hen::Nest *,int,int)' : overloaded member function not found in 'Hen'
1> f:\programy\microsoft visual c++ 2008\projects\cwiczenie 1\cwiczenie 1\hen.h(7) : see declaration of 'Hen'
ponadto gdy odkomentuje linijke hen.display(&nest);
w main.cpp dostaje taki o to bład :
1>f:\programy\microsoft visual c++ 2008\projects\cwiczenie 1\cwiczenie 1\main.cpp(14) : error C2664: 'Hen::display' : cannot convert parameter 1 from 'Hen::Nest *' to 'Nest *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Czy mozecie mi powiedziec co robie nie tak ?