函数后缀加与不加const的问题
dyw 2007-08-21 07:31:02 情况1:加const
.h文件中
TPtrC8 FolderPath() const; // 加const
.cpp文件中
TPtrC8 folderPath = FolderPath(); // 编译正确
或
const TDesC8& folderPath = FolderPath(); // 编译正确
情况2:不加const
.h文件中
TPtrC8 FolderPath(); // 不加const
.cpp文件中
TPtrC8 folderPath = FolderPath(); // 编译错误
或
const TDesC8& folderPath = FolderPath(); // 编译错误
不加const会发生编译错误,是什么道理?(使用Carbide.c++ 1.2编译)