Connecting Tech Pros Worldwide Forums | Help | Site Map

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

bigc
Guest
 
Posts: n/a
#1: Jul 19 '05
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()
{

}

WW
Guest
 
Posts: n/a
#2: Jul 19 '05

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


bigc wrote:[color=blue]
> 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"[/color]

Indent you code please!
[color=blue]
> class AAA;
>
> class BBB
> {
> AAA * a1;
> int tmp(){ a1=new AAA; }[/color]

The compiler has no idea how to make an AAA here!
[color=blue]
> };
>
> class AAA
> {
> BBB * b1;
> void tmp() { b1=new BBB;}
> };
>
> main()[/color]

int main(), in C++ there is no implicit int!!!
[color=blue]
> {
>
> }[/color]

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
}


--
WW aka Attila


John Ericson
Guest
 
Posts: n/a
#3: Jul 19 '05

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


"bigc" <bigc_cn@yahoo.com> wrote in message
news:20aa3c9a.0310031902.64a05f27@posting.google.c om...[color=blue]
> Hi
> I would be really appreciate if some one could tell me[/color]
what is[color=blue]
> the problem of the following code.
> The VC compiler aways complains
> "error C2512: 'AAA' : no appropriate default constructor[/color]
available"[color=blue]
>
> Thanks
>
> class AAA;
>
> class BBB
> {
> AAA * a1;
> int tmp(){ a1=new AAA; }[/color]

int tmp();
[color=blue]
> };
>
> class AAA
> {
> BBB * b1;
> void tmp() { b1=new BBB;}
> };
>[/color]

int BBB::tmp(){ a1 = new AAA; return 0; }
[color=blue]
> main()
> {
>
> }[/color]

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


Kevin Goodsell
Guest
 
Posts: n/a
#4: Jul 19 '05

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


WW wrote:
[color=blue]
>
> Indent you code please!
>[/color]

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
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

WW
Guest
 
Posts: n/a
#5: Jul 19 '05

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


Kevin Goodsell wrote:[color=blue]
> WW wrote:
>[color=green]
>>
>> Indent you code please!
>>[/color]
>
> 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).[/color]

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.

--
WW aka Attila


Mike Wahler
Guest
 
Posts: n/a
#6: Jul 19 '05

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


"Kevin Goodsell" <usenet1.spamfree.fusion@neverbox.com> wrote in message
news:lNsfb.1451$gA1.1224@newsread3.news.pas.earthl ink.net...[color=blue]
> WW wrote:
>[color=green]
> >
> > Indent you code please!
> >[/color]
>
> 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.[/color]

Moral: Do not post code which contains tab characters.

-Mike


Closed Thread