473,395 Members | 2,010 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,395 software developers and data experts.

Two classes dependent on each other, generating "syntax error: identifier 'NAME' "

Hi!

I think i know whats the problem but not how to solve it.

I have two classes, named A and B.

The A class has a list<B*>

And the B class has an pure virtual method declared as: void methodname(A*
Ap)

When compiling this, the compiler complains that the A class isnīt compiled
when trying to compile the B class. They are dependent on eachother, and can
not compile.

How can i solve this? I have looked through my two C++ books as good as i
could and googled for the answer. Any help would be greatly appreciated!
Btw, sorry for any typing or grammatical errors, english isnīt my native
language.

Best regards and Merry Christmas, Kent
Jul 22 '05 #1
2 2009
Kent wrote:
Hi!

I think i know whats the problem but not how to solve it.

I have two classes, named A and B.

The A class has a list<B*>

And the B class has an pure virtual method declared as: void methodname(A*
Ap)

When compiling this, the compiler complains that the A class isnīt compiled
when trying to compile the B class. They are dependent on eachother, and can
not compile.

How can i solve this? I have looked through my two C++ books as good as i
could and googled for the answer. Any help would be greatly appreciated!
Btw, sorry for any typing or grammatical errors, english isnīt my native
language.

Best regards and Merry Christmas, Kent

you mean like this ?

struct A;

struct B
{
virtual void func( A*);
};

struct A
{
int stuff;
};

virtual void B::func( A* p_a )
{
p_a->stuff = 2;
}

// typo warnings ... I did't check the above code.

Jul 22 '05 #2
"Kent" <ke******@mds.mdh.se> wrote:
Hi!

I think i know whats the problem but not how to solve it.

I have two classes, named A and B.

The A class has a list<B*>

And the B class has an pure virtual method declared as: void
Amethodname(A* p)

When compiling this, the compiler complains that the A class
isnīt compiled when trying to compile the B class. They are
dependent on eachother, and can not compile.

How can i solve this? I have looked through my two C++ books
as good as i could and googled for the answer. Any help
would be greatly appreciated! Btw, sorry for any typing or
grammatical errors, english isnīt my native language.

Best regards and Merry Christmas, Kent


You wan to read up on forward declarations. Here's a page I found on
Google that might help you (I'm sure there are lots of others):

http://www.adp-gmbh.ch/cpp/forward_decl.html
Jul 22 '05 #3

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

Similar topics

1
by: Larry Bates | last post by:
It doesn't happen often, but once in a while I will introduce a syntax error into a Python program I'm working on (in IDLE) and doing File-Check responds with the expected "Failed to check, syntax...
24
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office...
0
by: vladislav.moltchanov | last post by:
I am developing an Access tool for generating an Application MDB for data entry in a "large scale" project. At design stage I would like to keep open these two MDB. One current is generating forms...
6
by: craigbeanhead | last post by:
Hi, I'm teaching myself C from K&R2. I've come across something that I really don't understand. When I try to compile the following code (in VC++7), I get an "undeclared identifier" error. When...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
3
by: shifty shaker | last post by:
I've modified sql text and now i'm getting a syntax error that I cannot figure out....anyone? error occurs at the Insert Into line but the entire function is given in case you need it. ---...
0
by: Jim Avera | last post by:
On AIX, a template class containing a nested class which needs to be a friend provokes a warning: (W) A template dependent name that is a type must be qualified with "typename". and method...
3
by: harshadanarvekar | last post by:
Hi Everyone, Here is a part of javascript code that works well in FF2 but shows above error in IE6 and error "missing name after . operator" in NS8 function PopUp(idf,stepX,stepY,speed){
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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...
0
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...
0
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,...

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.