[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Is this a "using" bug in g++ 3.0.2?
From: |
Stuart Mentzer |
Subject: |
Is this a "using" bug in g++ 3.0.2? |
Date: |
Tue, 11 Dec 2001 04:47:38 -0500 |
Hello,
The code below is a small sample of a problem I ran into with g++ 3.0.2.
It seems like the using directive isn't making both the const and
non-const versions of an overloaded function visible.
The code works on Comeau online, IBM VAC++ 4, and Borland C++ 5.5.
[Obviously I don't need the using directive here but in my real app
I need it for a class template inheritance hierarchy.]
Thanks for any insight you can offer.
Stuart
// GCC 3.0.2 on Cygwin: Is this a "using" bug?
#include <iostream>
using namespace std;
struct Base {
Base() : val_( 22 ) {}
int val() const { return val_; }
int& val() { return ++val_; }
private:
int val_;
};
struct Der : public Base {
using Base::val; // Removing this line
// void f() const { cout << Base::val() << endl; } // or using this instead
void f() const { cout << val() << endl; } // of this line works
};
int main()
{
Der d;
d.f();
return 0;
}
/* Error message from: g++ -c try.cpp
try.cpp: In member function `void Der::f() const':
try.cpp:16: passing `const Der' as `this' argument of `int& Base::val()'
discards qualifiers
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Is this a "using" bug in g++ 3.0.2?,
Stuart Mentzer <=