Help! A hard (to me) corress-reference problem of C++

B

bigc

Hi
I would be really appreciate if some one could tell me what is
the problem of the following code.
The VC compiler aways complains
"error C2512: 'AAA' : no appropriate default constructor available"

Thanks

class AAA;

class BBB
{
AAA * a1;
int tmp(){ a1=new AAA; }
};

class AAA
{
BBB * b1;
void tmp() { b1=new BBB;}
};

main()
{

}
 
W

WW

bigc said:
Hi
I would be really appreciate if some one could tell me what is
the problem of the following code.
The VC compiler aways complains
"error C2512: 'AAA' : no appropriate default constructor available"

Indent you code please!
class AAA;

class BBB
{
AAA * a1;
int tmp(){ a1=new AAA; }

The compiler has no idea how to make an AAA here!
};

class AAA
{
BBB * b1;
void tmp() { b1=new BBB;}
};

main()

int main(), in C++ there is no implicit int!!!

class AAA;

class BBB {
AAA * a1;
int tmp(); // Move body...
};

class AAA {
BBB * b1;
void tmp() { b1=new BBB;}
};

inline BBB::tmp() { // ...here
a1=new AAA; // where AAA is known
}
 
J

John Ericson

bigc said:
Hi
I would be really appreciate if some one could tell me what is
the problem of the following code.
The VC compiler aways complains
"error C2512: 'AAA' : no appropriate default constructor available"

Thanks

class AAA;

class BBB
{
AAA * a1;
int tmp(){ a1=new AAA; }

int tmp();
};

class AAA
{
BBB * b1;
void tmp() { b1=new BBB;}
};

int BBB::tmp(){ a1 = new AAA; return 0; }
main()
{

}

main() returns an int, and so does BBB::temp().
 
K

Kevin Goodsell

WW said:
Indent you code please!

It was indented. Outlook Express hates you (I think it hates everyone -
it certainly hated me, and now I hate it right back). You might want to
try a different news reader. I used to use Forte Agent, which is pretty
good overall. Now I'm using Mozilla Thunderbird, which has some nice
features Agent doesn't, but is still in early beta and still missing a
lot, IMO (the 0.3 milestone should be out soon - last I checked it was
on it's 3rd release candidate). There's also the full Mozilla Suite, but
that may be more than you want.

Agent costs money, Mozilla is free (in both senses). There's also Free
Agent, for news only (no email).

-Kevin
 
W

WW

Kevin said:
It was indented. Outlook Express hates you (I think it hates everyone
- it certainly hated me, and now I hate it right back). You might
want to try a different news reader. I used to use Forte Agent, which
is pretty good overall. Now I'm using Mozilla Thunderbird, which has
some nice features Agent doesn't, but is still in early beta and
still missing a lot, IMO (the 0.3 milestone should be out soon - last
I checked it was on it's 3rd release candidate). There's also the
full Mozilla Suite, but that may be more than you want.

Agent costs money, Mozilla is free (in both senses). There's also Free
Agent, for news only (no email).

Yep. And spaces before TABs, in which case no reader will eat them. IIRC
someone told me some RFC once... I looked at 822, it says:

Writers of mail-sending programs should realize that there is no
network-wide definition of the effect of ASCII HT (horizontal-tab)
characters on the appearance of text at another network host...

So IMO it is veery simple. Do not use TABs in email. As in portable code.
BTW OutOfLuck kindly reminds you of that fact, since it does not insert tabs
if you press TAB. Only spaces. IIRC the only way to get TABs there is
copy-paste.

Anyways I think it is good to remember that TABs are not really "portable"
in an email. At least the ones at the beginning of line. And it is also
good to remember that I hate TABs for code formatting, because anything but
a most primitive code won't fit on 72 characters with with TABs for
indentation.
 
M

Mike Wahler

Kevin Goodsell said:
It was indented. Outlook Express hates you (I think it hates everyone -
it certainly hated me, and now I hate it right back). You might want to
try a different news reader. I used to use Forte Agent, which is pretty
good overall. Now I'm using Mozilla Thunderbird, which has some nice
features Agent doesn't, but is still in early beta and still missing a
lot, IMO (the 0.3 milestone should be out soon - last I checked it was
on it's 3rd release candidate). There's also the full Mozilla Suite, but
that may be more than you want.

Moral: Do not post code which contains tab characters.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top