level 12
v2abcd
楼主
#include <iostream>
template <typename T>
class a
{
public:
func(){std::cout << "func" << std::endl;};
};
template <typename T>
class b : public a<T>
{
public:
b()
{
func();
}
};
int main()
{
b<int> inlb;
return 0;
}
48test.cpp:7:10: error: ISO C++ forbids declaration of ‘func’ with no type [-fpermissive]
48test.cpp: In constructor ‘b<T>::b()’:
48test.cpp:16:14: error: there are no arguments to ‘func’ that depend on a template parameter, so a declaration of ‘func’ must be available [-fpermissive]
48test.cpp:16:14: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
2013年08月16日 07点08分
1
template <typename T>
class a
{
public:
func(){std::cout << "func" << std::endl;};
};
template <typename T>
class b : public a<T>
{
public:
b()
{
func();
}
};
int main()
{
b<int> inlb;
return 0;
}
48test.cpp:7:10: error: ISO C++ forbids declaration of ‘func’ with no type [-fpermissive]
48test.cpp: In constructor ‘b<T>::b()’:
48test.cpp:16:14: error: there are no arguments to ‘func’ that depend on a template parameter, so a declaration of ‘func’ must be available [-fpermissive]
48test.cpp:16:14: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)