473,394 Members | 1,750 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,394 software developers and data experts.

is this an compiler bug ???

i have two classes...

public class1{
// properties
class2 copy;
}

public class2{
// properties
create copy of class1;
}

i got error in class1 that "class2 is undefined"... however intelli show
shoutcut of class2. if compiler goes step by step; while declaring class1 it
is possible to be class2 undefined but it is too moronish...

how could i solve it ???

ps: if i take class1 bottom of class2 then it says that class1 is undefined
:)
Nov 17 '05 #1
4 873
sadun wrote:
i have two classes...

public class1{
// properties
class2 copy;
}

public class2{
// properties
create copy of class1;
}

i got error in class1 that "class2 is undefined"... however intelli
show shoutcut of class2. if compiler goes step by step; while
declaring class1 it is possible to be class2 undefined but it is too
moronish...

how could i solve it ???

ps: if i take class1 bottom of class2 then it says that class1 is
undefined :)


It's not a compiler bug, but a design bug. You simply can't have classes
that are co-dependent in this way. Since C++ classes are "value types",
when you create a member of "class2" inside "class1", you're actually
embedding a complete instance of class1 (unlike Java or C# when you're
effectively embedding a pointer or reference to an instance of class1).
Naturally if class2 contains a class1, then class1 cannot contain a class2,
since that would result in a data structure of infinite size (since 1
contains 2 contains 1 contains 2 ...).

Now, for what you really wanted:

class class2;

class class1
{
class2* m_c2;
};

class class2
{
class1* m_c1;
};

Sounds like you need to do some reading in an introductory C++ book.

-cd
Nov 17 '05 #2
thanks a lot... i have step by step c++.net but i don't like it. actually
its not good..

do you advice something ???
Nov 17 '05 #3
sadun wrote:
thanks a lot... i have step by step c++.net but i don't like it.
actually its not good..

do you advice something ???


"Accelerated C++" by Andrew Koenig & Barbara Moo is recommended.

"Thinking in C++" by Bruce Eckel is recommened, and available entirely in
HTML online at http://www.mindview.net/Books/TICPP/...ngInCPP2e.html

"The C++ Programming Language" by Bjarne Stroustrup is the seminal text on
C++ (since Bjarne is the inventor of the language).

-cd
Nov 17 '05 #4
thanks a lot again :)

you are so helpfull...
Nov 17 '05 #5

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

Similar topics

2
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild...
13
by: Bryan Parkoff | last post by:
You may notice that switch (...) is much faster than function that can gain a big improved performance because it only use JMP instruction however function is required to use CALL, PUSH, and POP...
10
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class...
7
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I saw cuj's conformance roundup, but the result is quite old. I think many people like me want to know newer c++ standard conformance test...
14
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
16
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...)...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
6
by: toton | last post by:
Hi, Anyone have a link to comparative study of different C++ compilers and how much they conform to C++ language standard? Most of the big platforms I know have GCC which well supports C++...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.