标题:c++疑惑
取消只看楼主
魔鬼之子
Rank: 1
来 自:地狱之都
等 级:新手上路
帖 子:100
专家分:0
注 册:2007-9-22
结帖率:71.43%
 问题点数:0 回复次数:0 
c++疑惑
# include <iostream.h>
# include <string.h>

template <class T>
T Max(T a,T b){
    return (a>b)?a:b;
}

void main(){
    int ix=12,iy=13;
    double dx=9.9,dy=7.8;
    string sx("abv"),sy("uid");
   
    cout<<"Type int:"<<Max(ix,iy)<<endl;
    cout<<"Type double:"<<Max(dx,dy)<<endl;
    cout<<"Type string:"<<Max(sx,sy)<<endl;
}

以上是源程序,可是在编译时却出现以下错误:

Compiling...
temexample.cpp
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(12) : error C2065: 'string' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(12) : error C2146: syntax error : missing ';' before identifier 'sx'
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(12) : error C2065: 'sx' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(12) : error C2065: 'sy' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(14) : error C2065: 'cout' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(14) : error C2297: '<<' : illegal, right operand has type 'char [10]'
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(14) : error C2065: 'endl' : undeclared identifier
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(15) : error C2297: '<<' : illegal, right operand has type 'char [13]'
c:\program files\microsoft visual studio\myprojects\first\temexample.cpp(16) : error C2297: '<<' : illegal, right operand has type 'char [13]'
执行 cl.exe 时出错.

First.exe - 1 error(s), 0 warning(s)
万望指教!
搜索更多相关主题的帖子: microsoft include double return visual 
2009-09-23 21:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-286604-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.074964 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved