Теперь получилось почти все .
не получается создать последний обьект :
class Ml
{
};
class X
{
public: void Eat( Ml m );
};
class Antilopa : Ml
{
};
class Lion : X
{
public:
void Eat( Ml ml )
{
printf("Lion eat antilopa" );
}
};
class Bizon : Ml
{
};
class Wolf : X
{
public:
void Eat( Ml ml )
{
printf("Wolf eat bizon" );
}
};
class Continent
{
public: X create_x();
Ml create_ml();
};
class Africa : public Continent
{
public:
Ml create_ml()
{
Antilopa *ant = new Antilopa();
}
X create_x()
{
Lion *ln = new Lion();
}
};
class America : public Continent
{
public:
Ml ml()
{
Bizon *ant = new Bizon();
}
X x()
{
Wolf *ln = new Wolf();
}
};
class AnimalWorld
{
private : Ml ml;
private : X x;
public:
AnimalWorld( Continent continent )
{
x = continent.create_x();
ml = continent.create_ml();
}
public:
void RunFoodChain()
{
x.Eat( ml );
}
};
int main()
{
Continent *africa = new Africa();
AnimalWorld *world = new AnimalWorld( *africa ); // вот тут ошибка компиляции
return 0 ;
}
Ошибка такая :
In function 'AnimalWorld::AnimalWorld[in-charge](Continent)':undefined reference to 'Continent::create_ml()'