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

Completing type of the class

I have 2 classes - Widget and Dialog. Dialog IS Widget. It contains
vector of Widgets. Widget get passed pointer to Dialog in constructor.
So both classes need to know about themselves.

//------------------------------------------------------------------
Dialog.hpp
//------------------------------------------------------------------
#include "Widget.hpp"

class Dialog : public Widget
{
vector<Widget*widgets_;
};
//------------------------------------------------------------------
Widget.hpp
//------------------------------------------------------------------
class Dialog;

class Widget
{
Widget( Dialog* parent );
};

The problem is that whenever I try to declare Dialog variable compiler
outputs that Dialog has incomplete type... Any suggestions?

Feb 15 '07 #1
2 1092
ms****@gmail.com wrote:
I have 2 classes - Widget and Dialog. Dialog IS Widget. It contains
vector of Widgets. Widget get passed pointer to Dialog in constructor.
So both classes need to know about themselves.

//------------------------------------------------------------------
Dialog.hpp
//------------------------------------------------------------------
#include "Widget.hpp"

class Dialog : public Widget
{
vector<Widget*widgets_;
};
//------------------------------------------------------------------
Widget.hpp
//------------------------------------------------------------------
class Dialog;

class Widget
{
Widget( Dialog* parent );
};

The problem is that whenever I try to declare Dialog variable compiler
outputs that Dialog has incomplete type... Any suggestions?
In the code above there is nothing to suggest the behaviour you described.

Try to ensure that 'Widget' class is defined before 'Dialog' class. You
can do that by tweaking the order in which your headers are included.

I also strongly recommend adding double inclusion guards to your headers.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 15 '07 #2
On Feb 15, 7:58 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
msc...@gmail.com wrote:
I have 2 classes - Widget and Dialog. Dialog IS Widget. It contains
vector of Widgets. Widget get passed pointer to Dialog in constructor.
So both classes need to know about themselves.
//------------------------------------------------------------------
Dialog.hpp
//------------------------------------------------------------------
#include "Widget.hpp"
class Dialog : public Widget
{
vector<Widget*widgets_;
};
//------------------------------------------------------------------
Widget.hpp
//------------------------------------------------------------------
class Dialog;
class Widget
{
Widget( Dialog* parent );
};
The problem is that whenever I try to declare Dialog variable compiler
outputs that Dialog has incomplete type... Any suggestions?

In the code above there is nothing to suggest the behaviour you described.

Try to ensure that 'Widget' class is defined before 'Dialog' class. You
can do that by tweaking the order in which your headers are included.

I also strongly recommend adding double inclusion guards to your headers.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Thank you very much... I've found the mistake. You were right, the
code was ok, but I have forgotten to include Dialog.hpp into main...
Feb 15 '07 #3

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

Similar topics

2
by: sudhashekhar30 | last post by:
hi all i have textbox in step in wizard control(step-10). there are 10 steps. so i want validation on every page and user can't move to other step without completing all correct entry. when i...
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to...
1
by: Ivan Ven Osdel | last post by:
The free Python editors/IDEs really do need work as far as code completion goes but I am hopeful. IMO Stani's Python Editor comes closest by providing some code sense through a combination of...
1
by: Ivan Ven Osdel | last post by:
Not really, I have just worked with them more. ----- Original Message ----- From: "Ali Servet Dönmez" <asd@pittle.org> To: python-list@python.org Sent: Wednesday, July 2, 2008 1:15:04 PM GMT...
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
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:
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,...
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
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.