c++/7467: method & class w/same name gives unhelpful error.

lerdsuwa@gcc.gnu.org lerdsuwa@gcc.gnu.org
Sat Oct 26 07:47:00 GMT 2002


Synopsis: method & class w/same name gives unhelpful error.

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Oct 26 07:47:07 2002
State-Changed-Why:
    Not a bug.  The following is a correct version of your code.
    First, you need to declare the class foo before using it.
    Second, to distinguish between class foo and function foo,
    you can use the scope operator "::".
    
    #include <iostream>
    
    class foo
    {
    public:
        foo() {};
    };
    
    class A
    {
    public:
        A() {};
        void foo() {};
        ::foo bar;
    };
    
    int main()
    {
        A oink;
    // gives same error as:
    // B oink;
    // (B not defn'd)
    }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7467



More information about the Gcc-prs mailing list