#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
阅读(64524) | 评论(0) | 转发(1) |