[LC++]g++ thinks default-constructed object is actually a function
Peter Poulsen
peter_poulsen at stofanet.dk
Wed Apr 7 14:43:02 UTC 2004
Dr Mark H Phillips <mark at austrics.com.au> writes:
> Hi,
>
> I know that if we do:
>
> Apple apple();
>
> then C++ interprets apple as a function taking no arguments and
> returning an Apple object. If we actually wanted apple to
> be an Apple object, constructed using the default constructor,
> then we should have done:
>
> Apple apple;
>
> But I've come across a situation where g++ (version 3.2.2) thinks
> I'm trying to define a function when really I'm trying to use
> a default constructor --- but in this situation just leaving off
> the brackets doesn't help!
>
> I've attached the example program. I'd be interested in people's
> ideas.
>
> Thanks,
>
> Mark.
>
Hi,
My help may not be that helpfull as I'm running gcc 2.95, but I managed
to get it running by changing the lines in the main function to the
following.
Ownrisk r;
Posint a(r, i);
std::cout<<"a = "<<a<<std::endl;
--
Yours
Peter Poulsen
More information about the tuxCPProgramming
mailing list