Hi,
let's say I define this two classes that do not inherit from one another.
I get an error at line 10: field "DataNoFather" has incomplete type.
1.Any idea what that means and how to fix it?
2. Is it possible to have a variable like DataNoSon labeled with type NoFather? (like I have in line 21)

thanks

class NoFather
{
	public:
		NoFather();
		~NoFather();
		NoFather GetDataNF() const;
		NoFather SetDataNF();

	private:
		NoFather DataNoFather;
};

class NoSon
{
	public:
		NoSon();
		~NoSon();

	private:

		NoFather DataNoSon;
};

Recommended Answers

All 2 Replies

You are trying to build absolutely senseless, absurd class NoFather (remember The House That Jack Built... ;) ?):

class NoFather {
...
private: NoFather DataNoFather;
};

Well, we have an object of type NoFather which has a member of type NoFather which has a member of type NoFather...

Formally at the point of DataNoFather declaration all the class NoFather was not completely constructed (that's why you get the message). In actual fact you are trying to construct an impossible thing...

commented: Thanks. +1

ArkM,
thank you. Now that you mention it, it is actually quite silly.
Ah!, no need to answer the second question. I found it is possible.
Thank you again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.