例2-1
老师,调试时他显示:c:\program files\microsoft visual studio\myprojects\22221\22221.cpp(15) : error C2731: 'main' : function cannot be overloaded
c:\program files\microsoft visual studio\myprojects\22221\22221.cpp(14) : see declaration of 'main'
执行 cl.exe 时出错.
// 22221.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
return 0;
}
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
bool flag=true;
cout<<flag<<endl;
cout<<boolalpha<<flag<<endl;
cout<<flag+5<<endl;
flag=0;
cout<<"执行语句flag=0;后flag的值为:"<<boolalpha<<flag<<endl;
flag=0.0;
cout<<"执行语句flag=0.0;后flag的值为:"<<boolalpha<<flag<<endl;
return 0;
}
老师,调试时他显示:c:\program files\microsoft visual studio\myprojects\22221\22221.cpp(15) : error C2731: 'main' : function cannot be overloaded
c:\program files\microsoft visual studio\myprojects\22221\22221.cpp(14) : see declaration of 'main'
执行 cl.exe 时出错.
我百度了但是还是找不出问题所在,还是请老师你帮我解答下。
例2.3.
# include<iostream>
using namespace std;
int main()
{
short i,j,m,n;
i=1000;
j=1000;
m=i+j;
n=i*j;
cout<<"m="<<m<<endl;
cout<<"n="<<n<<endl;
return 0;
}
老师 第二个程序也显示了同样的错误啊 怎么破
#include<iostream>
using namespace std;
int main()
{
int a,b,c,d;
a=4;
b=a;
a=5;
c=d=6;
c*=a;
d%=a+b;
cout<<"a="<<a<<endl
<<"b="<<b<<endl
<<"c="<<c<<endl
<<"d="<<d<<endl;
return 0;
}
例2.4
using namespace std;
int main()
{
int i=6,j,k,temp;
j=++i;
k=i++;
++i=1;
cout<<"i="<<i<<endl
<<"j="<<j<<endl
<<"k="<<k<<endl;
return 0;
}
例2.5
# include<iostream>
using namespace std;
int main()
{
char ch;
cout<<"请输入一个字母:";
cin>>ch;
ch=ch>='a'&&ch<='z'?ch-'a'+'A':ch;
cout<<"结果是:"<<ch<<endl;
return 0;
}
例2.7
# include<iostream>
using namespace std;
int main()
{
int ab,ac;
double b=3.14;
char c='A';
ab=int(b);
ac=int(c);
cout<<"b="<<b<<endl;
cout<<"ab="<<ab<<endl;
cout<<"c="<<c<<endl;
cout<<"ac="<<ac<<endl;
return 0;
}