关于c++模板成员的问题
我写了如下的一段代码:
#include <iostream>#include <typeinfo>#include <string>template<typename T> class A{public: A(int i = 0):value(i){} int get_value(){return value;}private: int value; template<typename Type> struct B; B<T> *bptr;};template<typename T> template<typename Type> struct A<T>::B{ B():str("hello world"){} void set_str(const char * s); const B *return_B();private: std::string str;};template<typename T> template <typename Type>void A<T>::B<Type>::set_str(const char * s){ str = s;}/**/template<typename Type> template <typename T> const A<Type>::B<T> *A<Type>::B<T>::return_B()//如果把const拿到*前面就可以编译通过{ return new B();}const int fun(){ return 4;}int main(){ return 0;}