Guest_imported
New member
- Jan 1, 1970
- 0
i have two classes (for example X and Y) and i need a method in each one which let me obtain an object from the other class. I´ve tested the next:
file x.hpp------------------
#include "y.hpp"
class X
{
...
public:
void &toY(Y &y)
{
y.function(...)
...
}
...
}
end of file x.hpp------------------
file y.hpp------------------
#include "x.hpp"
class Y
{
...
public:
void &toX(X &x) {...}
void function() {...}
...
}
end of file y.hpp------------------
file main.cpp------------------
#include "x.hpp"
#include "y.hpp"
main()
{
X ox;
Y oy;
ox.toY(oy); //ox change to oy
...
}
end of file main.cpp------------------
but in each file i´m including the class (file) that i want to get, so i get the compiling error:
"...'y' uses undefined class 'X'"
How can i make this work?
Thank you
bye
file x.hpp------------------
#include "y.hpp"
class X
{
...
public:
void &toY(Y &y)
{
y.function(...)
...
}
...
}
end of file x.hpp------------------
file y.hpp------------------
#include "x.hpp"
class Y
{
...
public:
void &toX(X &x) {...}
void function() {...}
...
}
end of file y.hpp------------------
file main.cpp------------------
#include "x.hpp"
#include "y.hpp"
main()
{
X ox;
Y oy;
ox.toY(oy); //ox change to oy
...
}
end of file main.cpp------------------
but in each file i´m including the class (file) that i want to get, so i get the compiling error:
"...'y' uses undefined class 'X'"
How can i make this work?
Thank you
bye