By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,991 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,991 IT Pros & Developers. It's quick & easy.

STL Vector of class

P: 2
Hi,
My program has a class and has a vector as the member. This is vector of the class itself. But during compilation it throws error that class is undefined and cannot be used. Below is my code snippet:

class xInterface {
private :
std::vector<xInterface> bInstance;

public:
xInterface () {};
xInterface (int x, int y)
{
/* my code ...*/
}

~xInterface() { };
}

C:\Documents and Settings\Disc\DesktopRAW\include\stlport\stl/type_traits.h(249) : error C2139: 'xInterface' : an undefined class is not allowed as an argument to compiler intrinsic type trait '__has_trivial_constructor'
c:\documents and settings\Disc\desktop\MyProject\include\xinstance. h(12) : see declaration of 'xInterface'
C:\Documents and Settings\Disc\Desktop\RAW\include\stlport\stl/_vector.h(137) : see reference to class template instantiation 'stlp_std::__type_traits<_Tp>' being compiled
with
[
_Tp=xInterface
]

Any pointers to resolve this?
Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
Hi,
My program has a class and has a vector as the member. This is vector of the class itself.
Just think what would happen if such an object stores *itself* in its own vector.
Better make that a vector of references or pointers to that class instead.

kind regards,

Jos
Aug 8 '07 #2

P: 2
Hi Jos,
Thanks for the reply. I had the similar implementation when I used VC++ libraries(VS 2005). But when I use this STL library alone this specific error is thrown. Even in linux platform, STL is used and it deosnt throw error.

Regards
Disc B
Aug 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.