Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2035400
  • 博文数量: 414
  • 博客积分: 10312
  • 博客等级: 上将
  • 技术积分: 4921
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-31 01:49
文章分类

全部博文(414)

文章存档

2011年(1)

2010年(29)

2009年(82)

2008年(301)

2007年(1)

分类: C/C++

2008-05-07 01:19:43

#include
using namespace std;
template class X
{
 T x;
public:
 X(T i):x(i){}
 void print()
 {
        cout< }
};
int main()
{
        X obj(10);
        obj.print();
        return 0;
}

[root@localhost zjj]# gcc  -o test test.cpp -lstdc++;./test
10
[root@localhost zjj]# gcc -c test.cpp
[root@localhost zjj]# g++ -o test test.o
[root@localhost zjj]# ./test
10
[root@localhost zjj]# cp test.cpp test.c
[root@localhost zjj]# gcc  -o test test.c -lstdc++
test.c:1:20: iostream: No such file or directory
[root@localhost zjj]# gcc  -c test.c
test.c:1:20: iostream: No such file or directory
[root@localhost zjj]# g++ -o test test.c
[root@localhost zjj]# ./test
10
阅读(997) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~