469,945 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

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%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

Jul 23 '05 #1
7 2356

"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%cgl%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%cgl%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%cgl%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%cgl%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.cz> skrev i en meddelelse
news:d0***********@ns.felk.cvut.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%cgl%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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike Pemberton | last post: by
3 posts views Thread by Kyle Teague | last post: by
14 posts views Thread by Dave | last post: by
8 posts views Thread by JustSomeGuy | last post: by
7 posts views Thread by alex221 | last post: by
12 posts views Thread by isliguezze | last post: by
17 posts views Thread by Isliguezze | last post: by
11 posts views Thread by Juha Nieminen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.