473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

error C2146 and error C2501

Tim
I created a header file including a Node Class and a
NodeList Class.

class Node{
Node* next;
};

class NodeList{
Node* first;
Node* last;
};

I wanna declare a NodeList inside the Node but since
NodeList is declared after Node it gives me this error

class Node{
Node* next;
NodeList list;
};
I get:
error C2146: syntax error : missing ';' before identifier 'list'
error C2501: 'Node::list' : missing storage-class or type specifiers
error C2501: 'Node::NodeList' : missing storage-class or type
specifiers

I tried to include both in different header files with each one
referencing the other but it was a wrose idea since the linker was
looping

Is there any way I can overcome this?
Thank you
Jul 22 '05 #1
1 4827

"Tim" <th*****@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
I created a header file including a Node Class and a
NodeList Class.

class Node{
Node* next;
};

class NodeList{
Node* first;
Node* last;
};

I wanna declare a NodeList inside the Node but since
NodeList is declared after Node it gives me this error

class Node{
Node* next;
NodeList list;
};
I get:
error C2146: syntax error : missing ';' before identifier 'list'
error C2501: 'Node::list' : missing storage-class or type specifiers
error C2501: 'Node::NodeList' : missing storage-class or type
specifiers

I tried to include both in different header files with each one
referencing the other but it was a wrose idea since the linker was
looping

Is there any way I can overcome this?
Thank you


Put the following in one header file

class Node; // forward declaration

class NodeList{
Node* first;
Node* last;
};

class Node{
Node* next;
NodeList list;
};

One class per header file is a good idea in general, but its not when
classes are as tightly dependent on each other as these two are.

John
Jul 22 '05 #2

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
1
by: geek04 | last post by:
i'm using pro*c to precompile my c++ code which accesses oracle 9i database, i'm running a oracle 9i client on my system on compiling the c++ file (generated by pro*c)i'm getting following...
2
by: kalpana.sinduria | last post by:
Hi all, how to remove the following complle error. When I compiling the code I get the following errors: Compiling... CDrtEachDefFeat.cpp d:\ include\common\cdrtintegfeat.h(39) : error...
3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
1
by: callmeastha | last post by:
hey guys i'm learning visual c++ and i'm getting errors on building the following program.it's from a book and so i expected it to run but it's giving errors please tell me what they mean and how to...
25
by: notahipee | last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For example 00 or 07. I was using a switch case. switch (int) { case 01: break; case 02: break;..... My problem arises at 08...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
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,...

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.