------- Comment #2 from sebor at roguewave dot com  2006-02-01 16:47 -------
Subject: Re:   New: "Class object();" is not interpreted as
 a call to default constructor

sylvain dot joyeux at m4x dot org wrote:
> The following testcase
> 
> #include <iostream>
> 
> bool flag = true;
> class guardian
> {
> public:
>     guardian() { flag = false; }
>     ~guardian() { flag = true; }
>     bool get() { return flag; }
> };
> 
> int main()
> {
>     guardian guard();
>     std::cout << guard.get() << std::endl;
>     std::cout << flag << std::endl;
> }
> 
> Leads to the error
> error: request for member 'get' in 'guard', which is of non-class type
> 'guardian ()()'

FWIW, here's the HP aCC 3 error message for this program. Does it make
it clear where the problem is?

Error 583: "t.cpp", line 15 # Left side of '.' requires a class object; 
type found was a function 'guardian ()'. Did you try to declare an 
object with a nested constructor call? Such a declaration is interpreted 
as a function declaration "guardian
     guard()" ["t.cpp", line 14].
         std::cout << guard.get() << std::endl;
                      ^^^^^

Martin


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26062

Reply via email to