R
rammel
class1.h
-----------
#ifndef CLASS1_H_
#define CLASS1_H_
#include "class2.h" // inclusion
class class2; // and forward
class class1
{
private:
class2 aRererence;
// --- gcc says: "error: field 'aRererence' has incomplete type" ---
public:
class1() :aReference( class2& aR ) {aReference = aR;};
// --- error according to the missing type of aReference ---
};
#endif /*CLASS1_H_*/
------------
class2.h
------------
#ifndef CLASS2_H_
#define CLASS2_H_
#include <vector>
#include "class1.h" // inclusion
class class1; // and forward
class class2
{
private:
std::vector<class1> someContainer;
public:
class2();
};
#endif /*CLASS2_H_*/
-----------
#ifndef CLASS1_H_
#define CLASS1_H_
#include "class2.h" // inclusion
class class2; // and forward
class class1
{
private:
class2 aRererence;
// --- gcc says: "error: field 'aRererence' has incomplete type" ---
public:
class1() :aReference( class2& aR ) {aReference = aR;};
// --- error according to the missing type of aReference ---
};
#endif /*CLASS1_H_*/
------------
class2.h
------------
#ifndef CLASS2_H_
#define CLASS2_H_
#include <vector>
#include "class1.h" // inclusion
class class1; // and forward
class class2
{
private:
std::vector<class1> someContainer;
public:
class2();
};
#endif /*CLASS2_H_*/