I am having trouble getting a piece of code to compile on VC++ 6.0...
Compiles fine on MAC OS X under X-Code....
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
I tried putting class myClass; in front of the class definition but it
didn't help...
errors...
C:\program files\microsoft visual studio\vc98\inc lude\list(29) : error
C2079: '_Value' uses undefined class 'myClass'
C:\Documents and Settings\userna me\Desktop\dele teme
\deleteme.cpp(1 5) : see reference to class template instantiation
'std::list<clas s myClass,class std::allocator< class myClass' being
compiled
c:\program files\microsoft visual studio\vc98\inc lude
\functional(185 ) : error C2079: 'value' uses undefined class 'myClass'
c:\program files\microsoft visual studio\vc98\inc lude
\list(285) : see reference to class template instantiation
'std::binder2nd <struct std::not_equal_ to<class myClass' being
compiled
C:\Documents and Settings\user\D esktop\deleteme
\deleteme.cpp(1 5) : see reference to class template instantiation
'std::list<clas s myClass,class std::allocator< class myClass' being
compiled 10 6445
On 2007-06-14 17:48, SpreadTooThin wrote:
I am having trouble getting a piece of code to compile on VC++ 6.0...
Compiles fine on MAC OS X under X-Code....
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
I tried putting class myClass; in front of the class definition but it
didn't help...
Except for having forgotten to include <stringit looks fine to me. Any
special reason for using VC++ 6, if not go and get VC++2005 Express and
it will work.
--
Erik Wikström
On Jun 14, 8:48 am, SpreadTooThin <bjobrie...@gma il.comwrote:
I am having trouble getting a piece of code to compile on VC++ 6.0...
Compiles fine on MAC OS X under X-Code....
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
I tried putting class myClass; in front of the class definition but it
didn't help...
errors...
C:\program files\microsoft visual studio\vc98\inc lude\list(29) : error
C2079: '_Value' uses undefined class 'myClass'
C:\Documents and Settings\userna me\Desktop\dele teme
\deleteme.cpp(1 5) : see reference to class template instantiation
'std::list<clas s myClass,class std::allocator< class myClass' being
compiled
c:\program files\microsoft visual studio\vc98\inc lude
\functional(185 ) : error C2079: 'value' uses undefined class 'myClass'
c:\program files\microsoft visual studio\vc98\inc lude
\list(285) : see reference to class template instantiation
'std::binder2nd <struct std::not_equal_ to<class myClass' being
compiled
C:\Documents and Settings\user\D esktop\deleteme
\deleteme.cpp(1 5) : see reference to class template instantiation
'std::list<clas s myClass,class std::allocator< class myClass' being
compiled
Works for me. I am using Visual C++ 2005 Express Edition though.
On Jun 14, 10:40 am, Erik Wikström <Erik-wikst...@telia. comwrote:
On 2007-06-14 17:48, SpreadTooThin wrote:
I am having trouble getting a piece of code to compile on VC++ 6.0...
Compiles fine on MAC OS X under X-Code....
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
I tried putting class myClass; in front of the class definition but it
didn't help...
Except for having forgotten to include <stringit looks fine to me. Any
special reason for using VC++ 6, if not go and get VC++2005 Express and
it will work.
--
Erik Wikström
Yes your right i forgot to include <stringin the posting here.. but
not in the code.
Well I'm trying to write cross platform code.. for windows and mac os
x...
All I have for development on windozs is Visual C++ 6.0
Just curious but the application I tried to make was a win32 console
application...
SpreadTooThin wrote:
>
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
At the point where myClass::object s is declared, the type myClass is
incomplete (it's not complete until the closing curly brace). The
behavior of a program that uses an incomplete type as a template
argument is undefined (in most cases, including this one). So an
implementation is not required to accept this code or to do anything
sensible with it.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book)
On 14 Jun, 17:58, SpreadTooThin <bjobrie...@gma il.comwrote:
On Jun 14, 10:40 am, Erik Wikström <Erik-wikst...@telia. comwrote:
On 2007-06-14 17:48, SpreadTooThin wrote:
I am having trouble getting a piece of code to compile
<snip code>
Except for having forgotten to include <stringit looks fine to me.
Yes your right i forgot to include <stringin the posting here.. but
not in the code.
That sort of mistake should never happen, and ensuring it doesn't is
trivial. If you are going to post code in a message, you should copy
and paste *directly* from your code editor into your message, as per
FAQ 5.8. Whatever you did instead - maybe you copied and pasted
separate snippets (bad), maybe you typed code directly into your post
(very bad) - you managed to leave a line out. In this case it was
obvious what you had omitted and it didn't affect things. Next time,
the bit you accidentally fail to post could be absolutely crucial to
understanding your problem and providing the answer. If that happens,
you might find you get little or no help, or, worse, you and the
people trying to help you could end up on a wild goose chase because
of the misunderstandin g.
Well I'm trying to write cross platform code.. for windows and mac os
x...
All I have for development on windozs is Visual C++ 6.0
That compiler is archaic. As Erik Wikström said, get Visual C++ 2005
Express. It's free to download so there's nothing stopping you getting
up to date.
Gavin Deane
On 14 Jun, 18:08, Pete Becker <p...@versatile coding.comwrote :
SpreadTooThin wrote:
#include <list>
class myClass
{
private:
std::string name;
std::list<myCla ssobjects;
};
At the point where myClass::object s is declared, the type myClass is
incomplete (it's not complete until the closing curly brace). The
behavior of a program that uses an incomplete type as a template
argument is undefined (in most cases, including this one). So an
implementation is not required to accept this code or to do anything
sensible with it.
I thought there was a rule about not using incomplete types as
template arguments, but Comeau online compiled the OP's code with no
problem. That's not inconsistent with undefined behaviour, but the
only thing I can find in the standard (1998 version) is a note in
14.3.1/2 that says "a template type argument may be an incomplete
type". Have I missed something?
Gavin Deane
Gavin Deane wrote:
On 14 Jun, 18:08, Pete Becker <p...@versatile coding.comwrote :
>SpreadTooThi n wrote:
>>#include <list> class myClass { private: std::string name; std::list<myCla ssobjects; };
At the point where myClass::object s is declared, the type myClass is incomplete (it's not complete until the closing curly brace). The behavior of a program that uses an incomplete type as a template argument is undefined (in most cases, including this one). So an implementati on is not required to accept this code or to do anything sensible with it.
I thought there was a rule about not using incomplete types as
template arguments, but Comeau online compiled the OP's code with no
problem. That's not inconsistent with undefined behaviour, but the
only thing I can find in the standard (1998 version) is a note in
14.3.1/2 that says "a template type argument may be an incomplete
type". Have I missed something?
Gavin Deane
I think the problem here is that the OP is creating an object of the
template instance type as part of the type in the template's argument.
This instance cannot be constructed...o r at least the standard doesn't
say what happens apparently.
If the OP were to use a pointer here I /think/ they would be ok. They
would need to create the object in an area of code where "myClass" was
fully defined.
Gavin Deane wrote:
On 14 Jun, 18:08, Pete Becker <p...@versatile coding.comwrote :
>SpreadTooThi n wrote:
>>#include <list> class myClass { private: std::string name; std::list<myCla ssobjects; };
At the point where myClass::object s is declared, the type myClass is incomplete (it's not complete until the closing curly brace). The behavior of a program that uses an incomplete type as a template argument is undefined (in most cases, including this one). So an implementati on is not required to accept this code or to do anything sensible with it.
I thought there was a rule about not using incomplete types as
template arguments, but Comeau online compiled the OP's code with no
problem. That's not inconsistent with undefined behaviour, but the
only thing I can find in the standard (1998 version) is a note in
14.3.1/2 that says "a template type argument may be an incomplete
type". Have I missed something?
No, I missed a bit of precision: what I said about myClass above applies
to standard library components, not to templates in general.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book)
Pete Becker wrote:
Gavin Deane wrote:
>On 14 Jun, 18:08, Pete Becker <p...@versatile coding.comwrote :
>>SpreadTooTh in wrote:
#include <list> class myClass { private: std::string name; std::list<myCla ssobjects; }; At the point where myClass::object s is declared, the type myClass is incomplete (it's not complete until the closing curly brace). The behavior of a program that uses an incomplete type as a template argument is undefined (in most cases, including this one). So an implementatio n is not required to accept this code or to do anything sensible with it.
I thought there was a rule about not using incomplete types as template arguments, but Comeau online compiled the OP's code with no problem. That's not inconsistent with undefined behaviour, but the only thing I can find in the standard (1998 version) is a note in 14.3.1/2 that says "a template type argument may be an incomplete type". Have I missed something?
No, I missed a bit of precision: what I said about myClass above applies
to standard library components, not to templates in general.
Sorry, hit Send too soon. The behavior is undefined, which means that
there are no constraints imposed by the standard on what the
implementation does. Once thing it can do is compile the code in the way
you'd expect. But even if it does compile in this simple form, I'm
betting it won't if you add inline functions, defined in the class body,
that do things to myClass::object s that require knowing something about
myClass.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peri |
last post by:
I'm trying to create Python parser/interpreter using ANTLR.
Reading grammar from language refference I found:
or_expr::= xor_expr | or_expr "|" xor_expr
For me it looks like infinite recursion. And so it says ANTLR. Maybe I
don't understand EBNF notation. For me it should look like this.
or_expr::= xor_expr | xor_expr "|" xor_expr
and in ANTLR grammar file like this:
|
by: Tim Clacy |
last post by:
Your expertise will be appreciated...
Here's a general templatised class; all specialisations of this class should
have a pointer to a specialisation of the same, templatised type:
template<typename T, const int N>
struct Base : T
{
typedef Base<T, N> Type;
|
by: Steven T. Hatton |
last post by:
The following may strike many of you as just plain silly, but it represents
the kind of delelima I find myself in when trying to make a design
decision. This really is a toy project written for the purpose of learning
to work with C++. It therefore makes some sense for me to give the
situation the amount of consideration presented below. To be quite honest,
I'm amazed at the amount there is to say about such a seemingly simple...
|
by: Jon Slaughter |
last post by:
I have a class that is basicaly duplicated throughout several files with
only members names changing according to the class name yet with virtually
the exact same coding going on.
e.g.
class A
{
std::vector<B*> Bs;
public:
|
by: SamIAm |
last post by:
Hi
I have a form named form1. I have a class called class1. I want to call a
recursive method in class1 called MyMethod()
I would like log info to a listbox, listbox1, on the form as MyMethod
performs its recursion. How do I pass an instance into class1 so that it can
add items to the listbox?
Should be easy I guess.
| |
by: Curious Student |
last post by:
Some places till now, I've seen function prototypes within functions
instead of in the global declaration space, which I thought was the
way.
I thought it was <I>only</I>:
int myfunction(int, int);
int main(void)
{
|
by: Christian E. Böhme |
last post by:
Hello all,
I ran into a little problem with recursive templates that I am not sure
what it has to do with, essentially, since I am currently limited in my
access to compilers (namely GCC 4.1) and until now had no chance of testing
the code with others. It may be an implementation detail or even in the
standard (which I have no access to, unfortunately). Or maybe I have hit
one of those cases whose solutions are "undefined" by the...
|
by: jman |
last post by:
i've got an object and i'd like to recursively call a function
within the class definition.
(i've simplified the code )
function myclass()
{
this.loop = function(index)
{
// ..work
|
by: tadmill |
last post by:
Is it possible to pass a generic parameter of the same class to to its
constructor, where the "T" type passed in the constructor is different
than the "T" type of the instanced class?
ie,
public class SomeList<T>
{
public SomeList(SomeList<TthisSomeList)
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |