473,605 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

std::list member in class? - vc6 problem?

class A
{
public:
std::list<A> m_a;
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...

How can I get it working with VC6?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}

Jul 23 '05 #1
7 2592

"Gernot Frisch" wrote:
class A
{
public:
std::list<A> m_a;
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...

How can I get it working with VC6?

--
-Gernot
int main(int argc, char** argv) {printf ("%silto%c%cf%c gl%ssic%ccom%c" ,
"ma", 58, 'g', 64, "ba", 46, 10);}


Storing pointers maybe?
Jul 23 '05 #2

"Eric Lilja" <er************ *@yahoo.com> schrieb im Newsbeitrag
news:d0******** **@news.island. liu.se...

"Gernot Frisch" wrote:
class A
{
public:
std::list<A> m_a;
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...

How can I get it working with VC6?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}


Storing pointers maybe?

// in .h:

class A
{
class DATA;
DATA* pData;
}

// in .cpp
class A::DATA
{
std::list<A> m_A;
};

worked for me - but it's not nice and I start disliking VC6 more and
more.
Jul 23 '05 #3

"Gernot Frisch" wrote:

"Eric Lilja" <er************ *@yahoo.com> schrieb im Newsbeitrag
news:d0******** **@news.island. liu.se...

"Gernot Frisch" wrote:
class A
{
public:
std::list<A> m_a;
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...

How can I get it working with VC6?

--
-Gernot
int main(int argc, char** argv) {printf ("%silto%c%cf%c gl%ssic%ccom%c" ,
"ma", 58, 'g', 64, "ba", 46, 10);}


Storing pointers maybe?

// in .h:

class A
{
class DATA;
DATA* pData;
}

// in .cpp
class A::DATA
{
std::list<A> m_A;
};

worked for me - but it's not nice and I start disliking VC6 more and more.


Off-topic:
Well, it is seven (or is it eight?) years old now. I used it for many years,
but now I use MSVC++ 7.1 or GCC 3.4.3. It's much easier to port
standards-conforming C++ code between the two than it was when I was using
MSVC++ 6.0 (and an older version of gcc). If you have to work with such an
old tool due to a misinformed decision by a non-technical boss, you have my
pity.

/ Eric
Jul 23 '05 #4
> "Gernot Frisch" wrote:

"Eric Lilja" <er************ *@yahoo.com> schrieb im Newsbeitrag
news:d0******** **@news.island. liu.se...

"Gernot Frisch" wrote:
class A
{
public:
std::list<A> m_a;
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...

How can I get it working with VC6?

--
-Gernot
int main(int argc, char** argv) {printf ("%silto%c%cf%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}


Storing pointers maybe?

// in .h:

class A
{
class DATA;
DATA* pData;
}

// in .cpp
class A::DATA
{
std::list<A> m_A;
};

worked for me - but it's not nice and I start disliking VC6 more and more.


Off-topic:
Well, it is seven (or is it eight?) years old now. I used it for many

years, but now I use MSVC++ 7.1 or GCC 3.4.3. It's much easier to port
standards-conforming C++ code between the two than it was when I was using
MSVC++ 6.0 (and an older version of gcc). If you have to work with such an
old tool due to a misinformed decision by a non-technical boss, you have my pity.


Well. I do not want to advocate for MSVC but this has entirely nothing to do
with the compiler but the library (std::list) implementation. I do not know
if standard requires the above code to work and if yes, the library is to
blame.

MV
Jul 23 '05 #5

"Marek Vondrak" <mv******@ceu.c z> skrev i en meddelelse
news:d0******** ***@ns.felk.cvu t.cz...
"Gernot Frisch" wrote:
>
> "Eric Lilja" <er************ *@yahoo.com> schrieb im Newsbeitrag
> news:d0******** **@news.island. liu.se...
>>
>> "Gernot Frisch" wrote:
>>> class A
>>> {
>>> public:
>>> std::list<A> m_a;
>>> };
>>>
>>> yields errorC2079: '_Value' uses undefined class 'A'
>>>
>>> using std::vector will work...
>>>
>>> How can I get it working with VC6?
>>>
>>> --
>>> -Gernot
>>> int main(int argc, char** argv) {printf ("%silto%c%cf%c gl%ssic%ccom%c" , >>> "ma", 58, 'g', 64, "ba", 46, 10);}
>>>
>>>
>>>
>>
>> Storing pointers maybe?
>
>
> // in .h:
>
> class A
> {
> class DATA;
> DATA* pData;
> }
>
> // in .cpp
> class A::DATA
> {
> std::list<A> m_A;
> };
>
> worked for me - but it's not nice and I start disliking VC6 more and more. >
>
Off-topic:
Well, it is seven (or is it eight?) years old now. I used it for many

years,
but now I use MSVC++ 7.1 or GCC 3.4.3. It's much easier to port
standards-conforming C++ code between the two than it was when I was
using
MSVC++ 6.0 (and an older version of gcc). If you have to work with such
an
old tool due to a misinformed decision by a non-technical boss, you have

my
pity.


Well. I do not want to advocate for MSVC but this has entirely nothing to
do
with the compiler but the library (std::list) implementation. I do not
know
if standard requires the above code to work and if yes, the library is to
blame.


The library is naturally restricted by the compiler so this is not
black-and-white. Actually I believe that the VC6.0 STL implementation is
reasonable, considering the limitations of the compiler.

MV

/Peter
Jul 23 '05 #6
Gernot Frisch wrote:
class A
{
public:
std::list<A> m_a;
The template parameter must be a complete type at the point of
instantiation.

Some other compilers have similar problems with your code; for
example, in mine, std::list<T> defines a struct list_node which
contains an object of type T.
};

yields errorC2079: '_Value' uses undefined class 'A'

using std::vector will work...
Not guaranteed by the standard.
How can I get it working with VC6?


This seems to work on my system, although I don't know if it's
standard:

template<int n> class A_
{
public:
std::list<A_> m_a;
};

typedef A_<0> A;

Jul 23 '05 #7

Old Wolf wrote:
Gernot Frisch wrote:
class A
{
public:
std::list<A> m_a;
The template parameter must be a complete type at the point of
instantiation.

This seems to work on my system, although I don't know if it's
standard:

template<int n> class A_
{
public:
std::list<A_> m_a;
};

typedef A_<0> A;


Definitely illegal. The argument to std::list<> must be a type. You
pass a template.

The best solution, which also reduces the number of headers included
was already mentioned. Use a pimpl idiom, and move the list to the
..cpp file. Another solution could be to store boost::ref<A>

HTH,
Michiel Salters

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3949
by: Mike Pemberton | last post by:
I'm sure there's a good explanation for this effect, but I get rather a strange output from this little test: #include <iostream> #include <list> int main() { std::list<int> int_list;
3
6798
by: Kyle Teague | last post by:
I have a list of pointers to structs as a private member of a class. If I call begin() in the same function as I added the data then no access violation occurs. However, if I try to call begin() in a member function of the same class I get a memory access violation. For example: // this is fine, no error void CBase::FuncA( void ) { plugin_info_t *plugin_info = new plugin_info_t;
14
5606
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for storing vertices of an arbitrary n-ary tree where a vertex contain pointers to its parent / children. These parent / child vertices need to stay put if we've got pointers to them somewhere! Am I correct in my assertion?
8
2830
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl list class must Ioverride in order for this to work?
5
1770
by: Eric Lilja | last post by:
Hello, consider this complete program (sorry, it's not minimal but I hope it's readable at least): #include <algorithm> #include <iostream> #include <vector> class Row { public:
7
2963
by: alex221 | last post by:
In need to implement a tree structure in which every node has arbitrary number of children the following code has come into mind: using std::list; template < class Contents class Tree_node{ Contents cn; list < BTree_node < Contents children; ........
12
2691
by: isliguezze | last post by:
template <class T> class List { public: List(); List(const List&); List(int, const T&); void push_back(const T &); void push_front(const T &); void pop_back();
17
4164
by: Isliguezze | last post by:
Does anybody know how to make a wrapper for that iterator? Here's my wrapper class for std::list: template <class Tclass List { private: std::list<T*lst; public: List() { lst = new std::list<T>(); } List(const List<T&rhs) { lst = new std::list<T>(*rhs.lst); } List(int n, const T& value) { lst = new std::list<T>(n, value); }
11
4152
by: Juha Nieminen | last post by:
Assume we have this: std::list<Typelist1(10, 1), list2(20, 2); std::list<Type>::iterator iter = list1.end(); list1.swap(list2); What happens here, according to the standard? 1) 'iter' still points to list1::end(). 2) 'iter' now points to list2::end().
0
8004
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1271
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.