Tag: template classes

C ++类模板未定义函数引用

当我在我的main函数中调用模板类“add”和“greater”中的两个函数时,我一直得到未定义的引用。 所以,我有:number.h #ifndef NUMBER_H #define NUMBER_H template class number { public: T x; T y; number (int a, int b){ x=a; y=b;} int add (T&); T greater (); }; #endif number.cpp #include “number.h” template int number::add (T& rezAdd){ rezAdd = x+y; return 1; } template T number::greater (){ return x>y? x : y; } 我的主文件是:resolver.cpp […]