bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a proble about const in g++


From: mayer
Subject: a proble about const in g++
Date: 18 Nov 2001 19:34:39 -0800

#include <iostream>
using namespace std;

class A
{
public:
     A(){}
    ~A(){}
public:
    void fun()
    {
        cout <<  "without cpnst " << endl;
    }
    void fun() const
    {
        cout << "with const" << endl;
    }
};

int main(int argc, char* argv[])
{
    A a1;
    const A a2;

    a1.fun();
    a2.fun();  // g++ con not compile it
                    // Error :
                    // passing const A as this in A::fun(void)

    return 0;
}


It is valid in stndard c++ but g++ can not compile it well, why?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]