c++_模板_1

版权声明:本文为博主原创文章,允许转载。如果转载,请注明出处。 https://blog.csdn.net/jjc_c/article/details/84201935

IDE:code::block

1

---

#ifndef TYPET_HPP
#define TYPET_HPP
template<class T>  class A{
    public:
         T g(T a,T b);
        // A();
};
#endif // TYPET_HPP

----------

#include <iostream>
#include"typet.hpp"

 //template<class T> A<T>::A(){}
  template<class T> T A<T>::g(T a,T b){
     return a+b;
 }
int main(){
     A<int> a;
     std::cout<<a.g(2,3.2)<<std::endl;
}

---------------

猜你喜欢

转载自blog.csdn.net/jjc_c/article/details/84201935