两个问题
第一个问题以前看见讨论过,不过当时没遇到就没留意,迷惑:
我的
template<typename Type>
class Matrix
{......}定义和声明必须放在一起!拆开就有错!(指的是分成.h文件和.cpp文件)是为什么?(win32 console application)
第二个问题在我得
template<typename Type>
class Matrix
{.....
void WritetoFile(ofstream &fout)//int i
{ ....}
.......
}
函数WritetoFile不能把输出文件流类对象ofstream &作为参数(换成string也不行,注:和头文件没有什么联系),但是换成int或者其他的基本类型,就好好的!
还有一点,把ofstream的对象放在函数体内也是可以得!为什么??
错误信息是:
error C2061: syntax error : identifier 'ofstream'