Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Compilation Error:Class name does not name a type.

Reply
Thread Tools

Compilation Error:Class name does not name a type.

 
 
anon
Guest
Posts: n/a
 
      04-19-2007
Ian Collins wrote:
> anon wrote:
>> Do you mean circularity with includes or what?

>
> class A has a member of type class B. Class B has a member of type
> class A. How big is class A?
>


Thanks for clarifications
I knew I have used something similar, but references instead of objects
 
Reply With Quote
 
 
 
 
sharat
Guest
Posts: n/a
 
      04-19-2007
still not clear

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-19-2007
* sharat:
> still not clear


In C++, if an object A contains another object B, it really directly
contains object B.

The size of object A is the size of its member object B plus the sizes
of whatever other members there are in object A, pluss the size of
compiler-inserted padding, if any.

Now, let type Y have some data member such that its size is at least 1.
If any object of type X contains an object of type Y, which in turn
contains an object of type X, which..., what's the size of an object of
type X? What's the size of an object of type Y?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
anon
Guest
Posts: n/a
 
      04-19-2007
sharat wrote:
> still not clear
>


You need to use pointers or references, instead of actual objects inside
your classes. Like in these headers:

//file1.h
#ifndef FILE1_H
#define FILE1_H

class zone_class;
class plot_class
{
public:
int p;
zone_class& zone_obj;
void fun1();

};
#endif

//file2.h
#ifndef FILE2_H
#define FILE2_H

class plot_class;
class zone_class
{
public:
int z;
plot_class& plot_obj;
void fun_zone();
};
#endif

Otherwise, object of class zone_class would contain an object of
plot_class class, which contains object of zone_class class, ... , to
infinity.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation error with seperate compilation C__chp C++ 4 02-15-2008 03:57 PM
Compilation error CS0246: The type or namespace name 'MySql' could not be found Benny Dein ASP .Net 0 03-20-2006 06:30 PM
Compilation Error "The name Convert is not declared" fabrice ASP .Net 2 08-18-2005 05:03 PM
Compilation fails when a windows form user control is assigned a strong name but it refers to an activex control which does not have strong name ashish_gokhale ASP .Net Web Controls 0 05-05-2005 01:38 PM
Compilation Error: dropdownlist does not contain a definition for selected value Ashish Kanoongo ASP .Net 1 02-03-2004 10:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57