Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

xropi

mutual type refs

This topic is 5680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In the following situation there are mutual references. The compiler tells me: error C2027: use of undefined type 'CTest'
          
class	CTest;

class CSmall {
	CTest::TT	m_x:         // error reported here

};


class CTest {
	typedef int TT;       // or any other type

	vector<CSmall>		m_xx;
};
          
If TT was in global scope, my problem would be solved. But what if this condition can't be realized? How would you handle that? [edited by - xropi on November 4, 2002 6:48:28 AM]

Share this post


Link to post
Share on other sites
Advertisement

    
#include <vector>

using namespace std;

class CSmall;


class CTest {
public:
typedef int TT; // or any other type

private:
vector<CSmall> m_xx;
};

class CSmall {
CTest::TT m_x;
};


[edited by - Pepe on November 4, 2002 7:00:31 AM]

Share this post


Link to post
Share on other sites
That won''t work. You need the structure implementation to create a vector of it (ISTR).

The only way i can see is to make m_xx a vector or CSmall*s.

HTH, Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates

Share this post


Link to post
Share on other sites
Evil Bill, what dou you want to mean with?
quote:

That won''t work.


I''ve compiled it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!