J
jesse
#include <string>
#include <iostream>
template <typename T>
class Base
{
public:
Base(){
};
~Base(){
};
void talk(){
std::cout << " this is base talk" << std::endl;
};
void talk(bool flag){
std::cout << " this is base talk with flag" << std::endl;
};
void sing(){
std::cout << " this is base sing" << std::endl;
};
};
template <typename T>
class Derivedublic Base<T>
{
public:
Derived():Base<T>()
{
};
~Derived()
{
};
};
template <>
class Derived<int>ublic Base<int>
{
public:
Derived():Base<int>()
{
talk(); // <--------------- Location A;
talk(false); // <--------------- Location B;
sing(); // <--------------- Location C;
};
~Derived()
{
};
void talk(){
std::cout << " this is derived talk" << std::endl;
};
};
int main(void)
{
Derived<int> m;
m.talk();
return 0;
}
when i compile it with g++, i get the following error:
/*
* mytest.cpp: In constructor `Derived<int>:erived()':
* mytest.cpp:43: no matching function for call to
`Derived<int>::talk(bool)'
* mytest.cpp:49: candidates are: void Derived<int>::talk()
*/
I just wondering why in location C, the method sing() can be called
while talk(false) can not be called since both are in the base class.
when i compile it with MS VStudio. i get similar error:
Compiling...
mytest.cpp
D:\code\c++\TestGcc\mytest.cpp(43) : error C2660: 'talk' : function does
not take 1 parameters
Error executing cl.exe.
TestGcc.exe - 1 error(s), 0 warning(s)
is this a bug of implementation in compiler?
#include <iostream>
template <typename T>
class Base
{
public:
Base(){
};
~Base(){
};
void talk(){
std::cout << " this is base talk" << std::endl;
};
void talk(bool flag){
std::cout << " this is base talk with flag" << std::endl;
};
void sing(){
std::cout << " this is base sing" << std::endl;
};
};
template <typename T>
class Derivedublic Base<T>
{
public:
Derived():Base<T>()
{
};
~Derived()
{
};
};
template <>
class Derived<int>ublic Base<int>
{
public:
Derived():Base<int>()
{
talk(); // <--------------- Location A;
talk(false); // <--------------- Location B;
sing(); // <--------------- Location C;
};
~Derived()
{
};
void talk(){
std::cout << " this is derived talk" << std::endl;
};
};
int main(void)
{
Derived<int> m;
m.talk();
return 0;
}
when i compile it with g++, i get the following error:
/*
* mytest.cpp: In constructor `Derived<int>:erived()':
* mytest.cpp:43: no matching function for call to
`Derived<int>::talk(bool)'
* mytest.cpp:49: candidates are: void Derived<int>::talk()
*/
I just wondering why in location C, the method sing() can be called
while talk(false) can not be called since both are in the base class.
when i compile it with MS VStudio. i get similar error:
Compiling...
mytest.cpp
D:\code\c++\TestGcc\mytest.cpp(43) : error C2660: 'talk' : function does
not take 1 parameters
Error executing cl.exe.
TestGcc.exe - 1 error(s), 0 warning(s)
is this a bug of implementation in compiler?