小程序错误,帮忙看看~~:)
#include<iostream.h>
template<class T>
class Sample
{
T n;
public:
Sample(T i){n=i;}
void operator++();
void disp(){cout<<"n="<<n<<endl;
}
template<class T>
void Sample<T>::operator ++()
{
n+=1; //试试double能不能++?
}
void main()
{
Sample<char> s('a');
s++;
s.disp();
}
错误为
a - Win32 Debug--------------------
Compiling...
s.cpp
c:\program files\microsoft visual studio\myprojects\zxa\s.cpp(23) : fatal error C1075: end of file found before the left brace '{' at 'c:\program files\microsoft visual studio\myprojects\zxa\s.cpp(4)' was matched
Error executing cl.exe.
s.obj - 1 error(s), 0 warning(s)