 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Daniel Guest
|
Posted: Tue May 15, 2007 4:52 am Post subject: compiler error overloading function in CRTP context |
|
|
I don't understand why the compiler balks at the following:
//---------begin code -----------
template <typename T>
struct Base {
void foo() const {}
};
struct Derived : public Base<Derived> {
void foo(const int arg) const {}
};
int main(){
Derived d;
d.foo(15);
d.foo(); //won't compile... says that the "only candidate function
is void Derived::foo(int) "
}
//-----------end code -----------
It seems to me that the Derived::foo(int) should not hide Base::foo(),
but that's what appears to be happening. I've tried compiling with
IRIX gcc and Linux g++.
Can anyone explain why the compiler won't allow this?
Thanks in advance,
Daniel
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
John Moeller Guest
|
Posted: Wed May 16, 2007 4:25 am Post subject: Re: compiler error overloading function in CRTP context |
|
|
John Moeller wrote:
Oops, this should be Base<Derived>, not Base.
--
John Moeller
fishcorn (AT) gmail (DOT) com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|