13.cpp(20) : error C2143: syntax error : missing ';' before '{'想问问哪里出错了 10
#include<stdio.h>main(){inta,b;intc=10;printf("输入值ab:\n");scanf("%d%d",&a,&b);printf(...
#include <stdio.h>
main()
{
int a,b;
int c=10;
printf("输入值ab:\n");
scanf("%d%d",&a,&b);
printf("%d+%d=%d\n",a,b,a+b);
if(c>(a+b))
{
printf("多\n");
}
else if(c<(a+b))
{
printf("少\n");
}
else(c=(a+b))
{
printf("刚刚好");
}
return 0;
}
删除错误的那行就没有问题了 这是为什么呢? 展开
main()
{
int a,b;
int c=10;
printf("输入值ab:\n");
scanf("%d%d",&a,&b);
printf("%d+%d=%d\n",a,b,a+b);
if(c>(a+b))
{
printf("多\n");
}
else if(c<(a+b))
{
printf("少\n");
}
else(c=(a+b))
{
printf("刚刚好");
}
return 0;
}
删除错误的那行就没有问题了 这是为什么呢? 展开
1个回答
展开全部
#ifndef ITEM_BASE
#define ITEM_BASE
#include<iostream>
using namespace std;
class person{
public:
person();
person(string, string, string);
string getName() const;
string getSSN() const;
string getAddress() const;
void setName(string );
void setSSN(string);
void setAddress(string);
void print();
person& operator=(const person&);
private:
string Name;string SSN;string address;
};
#endif
-----------------------------------------------------------------------------
#include<iostream>
#include "person.h"
person::person(){
Name="no name yet"; SSN="no ssn yet"; address="no address yet";
}
person::person(string name, string ssn, string add)
{
Name=name; SSN=ssn; address=add;
}
string person::getName() const{ return Name;}
string person::getSSN() const{ return SSN;}
string person::getAddress() const{ return address;}
void person::setName(string name){ Name=name;}
void person::setSSN(string ssn){ SSN=ssn;}
void person::setAddress(string add){ address=add;}
void person::print(){
string owner=getName();
string ssn=getSSN();
string add=getAddress();
cout<<"Owner:"<<owner.c_str()<<endl;
cout<<"SSN:"<<ssn.c_str()<<endl;
cout<<"Address:"<<add.c_str()<<endl;
}
person & person::operator=(const person &p){
person *per = new person();
per->setName(p.getName());
per->setSSN(p.getSSN());
per->setAddress(p.getAddress());
return *per;
}
int main()
{
person p;
return 0;
}
#define ITEM_BASE
#include<iostream>
using namespace std;
class person{
public:
person();
person(string, string, string);
string getName() const;
string getSSN() const;
string getAddress() const;
void setName(string );
void setSSN(string);
void setAddress(string);
void print();
person& operator=(const person&);
private:
string Name;string SSN;string address;
};
#endif
-----------------------------------------------------------------------------
#include<iostream>
#include "person.h"
person::person(){
Name="no name yet"; SSN="no ssn yet"; address="no address yet";
}
person::person(string name, string ssn, string add)
{
Name=name; SSN=ssn; address=add;
}
string person::getName() const{ return Name;}
string person::getSSN() const{ return SSN;}
string person::getAddress() const{ return address;}
void person::setName(string name){ Name=name;}
void person::setSSN(string ssn){ SSN=ssn;}
void person::setAddress(string add){ address=add;}
void person::print(){
string owner=getName();
string ssn=getSSN();
string add=getAddress();
cout<<"Owner:"<<owner.c_str()<<endl;
cout<<"SSN:"<<ssn.c_str()<<endl;
cout<<"Address:"<<add.c_str()<<endl;
}
person & person::operator=(const person &p){
person *per = new person();
per->setName(p.getName());
per->setSSN(p.getSSN());
per->setAddress(p.getAddress());
return *per;
}
int main()
{
person p;
return 0;
}
追问
什么鬼
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询