 |
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 |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|