具体代码
// class templates
#include<iostream>
using namespace std;
template <class T>
class pair {
T value1;T value2;
public:
pair (T first, T second) {
value1=first;
value2=second;
}
T getmax ();
};
/*template <class T>
T pair::getmax (){
T retval;
retval = value1>value2? value1 : value2;
return retval;
}
int main () {
pair myobject (100, 75);
cout << myobject.getmax();
return 0;
}*/
编译错误:
C:\Users\hyf\Desktop\VC++program\Cpp1.cpp(13) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
Cpp1.exe - 1 error(s), 0 warning(s)
下面代码没用,只运行了类模块说明,定义