- 论坛徽章:
- 0
|
在VS2010学习版中这个可以运行!为啥在VS2010旗舰版中运行不了啊!
错误提示在下面- #include<iostream>
- using namespace std;
- template <typename T>
- void jhuan(T &a,T &b);
- struct KT
- {
- char name[40];
- double xinshui;
- int floor;
- };
- template <>void jhuan<KT>(KT &kt1,KT &kt2);
- void show(KT &kt);
- int main()
- {
- system ("color d");
- int i=10,j=20;
- cout<<"没用模板之前:\n";
- cout<<"i="<<i<<",j="<<j<<endl;
- jhuan(i,j);
- cout<<"使用模板之后:\n";
- cout<<"i="<<i<<",j="<<j<<endl;
- KT mzx={"mazxiao",4324.56,3};
- KT yys={"yyansheng",4200.78,5};
- cout<<"没用模板之前:\n";
- show(mzx);
- show(yys);
- cout<<"使用模板之后:\n";
- jhuan(mzx,yys);
- show(mzx);
- show(yys);
- return 0;
- }
- template <typename T>
- void jhuan(T &a,T &b)
- {
- T t;
- t=a;
- a=b;
- b=t;
- }
- template <>void jhuan<KT>(KT &kt1,KT &kt2)
- {
- double t1;
- int t2;
- t1=kt1.xinshui;
- kt1.xinshui=kt2.xinshui;
- kt2.xinshui=t1;
- t2=kt1.floor;
- kt1.floor=kt2.floor;
- kt2.floor=t2;
- }
- void show(KT &kt)
- {
- cout<<"姓名:"<<kt.name<<endl;
- cout<<"薪水:"<<kt.xinshui<<endl;
- cout<<"工作层:"<<kt.floor<<endl;
- }
复制代码 1>e:\c++\1\1\main.cpp(1): fatal error C1083: 无法打开包括文件:“iostream”: No such file or directory
1>
有时候还出现..."istream":No such file or directory!
这是先建立一个win32控制台程序再添加Main函数,运行不了!
建立空工程也是运行不了,在VS2010学习版中是没有任何问题的! |
|