Is this a bug or I misunderstand?

maggie_shh maggie_shh@hotmail.com
Mon Jun 17 00:01:00 GMT 2002


What I mean is that maybe we should not permit func-decl in function-scope
in g++,
because It is useless.
----- Original Message -----
From: "maggie_shh" <maggie_shh@hotmail.com>
To: "Andrew Pinski" <pinskia@physics.uc.edu>
Cc: <gcc@gnu.org>
Sent: Monday, June 17, 2002 2:34 PM
Subject: Re: Is this a bug or I misunderstand?


> but If I change "A b();" to "A b(1);",It will be right and the behaviour
is
> as I had said.
> It show us that the c++ compiler do not take it as local function
> declaration.
>
> btw:Is it useful to declare a function in another function?As I know,C++
> standard forbide
> function definition in another function,but permit function declaration in
> function scope.
> but
> If we want to use another function out of current file scope,we can
declare
> it outside of function.
> It will not change the behaviour of our codes.
>
> Best Regards
>     Maggie
> ----- Original Message -----
> From: "Andrew Pinski" <pinskia@physics.uc.edu>
> To: "Maggie Mitchell" <maggie_shh@hotmail.com>
> Cc: <gcc@gnu.org>
> Sent: Monday, June 17, 2002 2:12 PM
> Subject: Re: Is this a bug or I misunderstand?
>
>
> > This is common mistake for beginners of c++ and some advance c++ people.
> > The problem is the statement `A b();' is not a statement declaring a
> > variable with type of b and using the default constructor but rather
> > declaring a function that takes no variables and returns an `A' object.
> >
> >
> > Thanks,
> > Andrew Pinski
> >
> >
> > On Monday, June 17, 2002, at 01:55 , Maggie Mitchell wrote:
> >
> > > //The codes begin
> > > #include <stdio.h>
> > > class A {
> > > public:
> > >    A(int i=0)
> > >        {
> > >        printf("hello\n");
> > >        }
> > > };
> > > int main()
> > > {
> > > printf("begin\n");
> > > A a;
> > > printf("----\n");
> > > A b();
> > > printf("end\n");
> > > return 0;
> > > }
> > > //codes end
> > > I think the result should be
> > > begin
> > > hello
> > > ------
> > > hello
> > > end
> > >
> > > but the result  is
> > > are
> > > begin
> > > hello
> > > -----
> > > end
> > >
> > > why?Is It a bug of g++ or I misunderstand the behaviour of
constructor?
> > >
> > > Regards
> > >   Maggie
> > >
> > >
> > > _________________________________________________________________
> > > Send and receive Hotmail on your mobile device: http://mobile.msn.com
> > >
> > >
> > >
> >
>



More information about the Gcc mailing list