I'm trying to write a code that looks something like this:
class Foo{
...
}
....
class World{
public:
World(int a, Foo first, Foo second);
...
}
I am very new. to c++ and I cannot figure out how to make the second class use the first class in the parameter of the constructor of the second class. Any suggestions??
class Foo
{
public:
int x;
};
class World
{
int a;
int b;
public:
World(int d, Foo first, Foo second)
{
a = first.x;
b = second.x;
}
};
int main()
{
Foo one;
Foo two;
World three(7, one, two); // construtor of World object, using two Foo objects
}