473,395 Members | 1,468 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.

class definition position?

Dear all,

For example,

class CA;

class CB {
public:
int m_iY;
CA m_oCA;
};

class CA {
public:
int m_iX;
};

I use BCB compiler, but it says "undefined structure CA".
The style is standard, why it can't compile well?
I know if I put full definition of CA before CB, it's ok.
Thanks for your answer.

Regards,
cylin.
Jul 19 '05 #1
2 1521

"cylin" <cy***@avant.com.tw> wrote in message
news:bh************@ID-154203.news.uni-berlin.de...
Dear all,

For example,

class CA;

class CB {
public:
int m_iY;
CA m_oCA;
};

class CA {
public:
int m_iX;
};

I use BCB compiler, but it says "undefined structure CA".
The style is standard, why it can't compile well?


Because the compiler does not know the size of CA.
A forward declarartion only tells the compiler that such a class
exists somewhere but does not tell it's size which is required here.
Else use a pointer/reference to CA in CB.

HTH.
--
With best wishes,
J.Schafer
Jul 19 '05 #2
Thanks all, I learn much.

Regards,
cylin.
Jul 19 '05 #3

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

Similar topics

9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
15
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...
2
by: Jops via DotNetMonster.com | last post by:
How can I move the cursor on the screen and press buttons (like a human user) programmatically? I don't know what it is called so I couldn't google but in Java it is done via Robot-class. --...
5
by: uralmutlu | last post by:
Hi, I have the following classes (in extremely simplified form): class Inner{ int num; public: void SetNo(int n){num=n;} int GetNo(){return num;} Test* MakeTest();
11
by: food4uk | last post by:
Dear all : I am not good at programming, please give a hand. My data structure is very similar as an array. I actually can use the std::vector as container to organize my data objects. However,...
15
by: Victor Bazarov | last post by:
Hello, Take a look at this program: ----------------------------------- class B { B(const B&); B& operator=(const B&); public: B(int);
3
by: eholz1 | last post by:
Hello php group, I have a dev server running php 5.0 and apache 2.2, I have created some php files that create classes, etc All works well with this. But when I copy the files to my hosting...
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
3
card
by: card | last post by:
Ah, the joy of generic programming. Ok. Here's my problem. I have a templated class with a internally defined structure type. Within the class, I have some member functions whose return value is...
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:
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.