_______________你快来呀。。。。帮帮我呀。。。。。。。。。

TemplatesGuy 2005-04-13 04:58:59
#include <iostream>
using namespace std;
template <typename T>
class testClass
{
public:
static int _data;
};
int testClass<int>::_data=1;
int testClass<char>::_data=2;

int main()
{
cout<<"Hello!";
cin.get();
return 0;
}
================================
以上在dev-c++最新版本编译不过:
提示:
F:\C++ STL>g++ 1.cpp
1.cpp:9: error: too few template-parameter-lists
1.cpp:9: error: expected `,' or `;' before '=' token
1.cpp:10: error: too few template-parameter-lists
1.cpp:10: error: expected `,' or `;' before '=' token

请问是怎么回事呢?
cl.exe2003编译正常!


...全文
99 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shazi_pig 2005-04-13
  • 打赏
  • 举报
回复
我的电脑上面也可以的。
应该不是有问题的。
TemplatesGuy 2005-04-13
  • 打赏
  • 举报
回复
@ kobefly(科比---开始学习c++!)

真的吗?
啊。。奇怪我的怎么不行呀。。。
我的朋友也说是可以的啊。。郁闷

不过在MinGW Developer Studio 2.05中反而可以。

Compiler: Default compiler
Executing g++.exe...
g++.exe "F:\C++ STL\1.cpp" -o "F:\C++ STL\1.exe" -g3 -I"d:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"d:\Dev-Cpp\include\c++\3.4.2\backward" -I"d:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"d:\Dev-Cpp\include\c++\3.4.2" -I"d:\Dev-Cpp\include" -L"d:\Dev-Cpp\lib" -g3
F:\C++ STL\1.cpp:9: error: too few template-parameter-lists
F:\C++ STL\1.cpp:9: error: expected `,' or `;' before '=' token
F:\C++ STL\1.cpp:10: error: too few template-parameter-lists
F:\C++ STL\1.cpp:10: error: expected `,' or `;' before '=' token

Execution terminated
healer_kx 2005-04-13
  • 打赏
  • 举报
回复
看着没有问题。
kobefly 2005-04-13
  • 打赏
  • 举报
回复
不会吧

在我这里运行正常的啊
llf_hust 2005-04-13
  • 打赏
  • 举报
回复
static int _data; //static T _data;

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧