不想敲代码1 2022-04-27 10:49 采纳率: 82.8%
浏览 17
已结题

function类中的exist函数哪里出现了错误,可以改正吗

#include
using namespace std;
class date{
private:
int year;
int month;
int day;
public:
date(){
year=2022;
month=01;
day=01;
}
date(int myear,int mmonth,int mday){
year=myear;
month=mmonth;
day=mday;
}
void setyear(int myear){
year=myear;
}
int getyear(){
return year;
}
void deyear(){
cout<<year<<endl;
}
void setmonth(int mmonth){
month=mmonth;
}
int getmonth(){
return month;
}
void demonth(){
cout<<month<<endl;
}
void setday(int mday){
day=mday;
}
int getday(){
return day;
}
void deday(){
cout<<day<<endl;
}
void show(){
cout<year<<"."<month<<"."<day<<endl;
}

};
class people{
private:
string card;
int phone;
string name;
int done;
date time;
bool result;
public:
people(){
card="0000";
phone=0;
name="张三";
done=0;
time.setyear(2022);
time.setmonth(01);
time.setday(01);
result=0;
}
people(string card,int phone,string name,int done,date time,bool result){
this->card=card;
this->phone=phone;
this->name=name;
this->done=done;
this->time=time;
this->result=result;
}
void setcard(string mcard){
card=mcard;
}
string getcard(){
return card;
}
void decard(){
cout<<card<<endl;
}
void setphone(int mphone){
phone=mphone;
}
int getphone(){
return phone;
}
void dephone(){
cout<<phone<<endl;
}
void setname(int mname){
card=mname;
}
string getname(){
return name;
}
void dename(){
cout<<name<<endl;
}
void setdone(int mdone){
done=mdone;
}
int getdone(){
return done;
}
void dedone(){
cout<<done<<endl;
}
void settime(date mtime){
time=mtime;
}
date gettime(){
return time;
}
void detime(){
time.show();
}
void setresult(int mresult){
result=mresult;
}
bool getresult(){
return result;
}
void deresult(){
cout<<result<<endl;
}
};
class functions{
private:
people *arry;
int m_size;
int maxn;
int n_size;
public:
functions(int m)
{
arry=new people[m];
m_size=m;
maxn=0;
n_size=0;
}
functions()
{
arry=new people[1000];
m_size=1000;
maxn=0;
n_size=0;
}
void add(people x){
if (n_size<m_size){
arry[n_size]=x;
n_size++;
}
}
void findd(people x){
string m,n;
cin>>m;
for(int i=0;i<n_size;i++){
n=arry[i].getcard();
if(n==m){
this->arry[i].dename();
this->arry[i].decard();
this->arry[i].dephone();
this->arry[i].dedone();
this->arry[i].detime();
this->arry[i].deresult();
}else cout<<"未找到"<<endl;
}
}
void correct(people x){//未完成
string m,n;
cin>>m;
int pdone;
bool presult;
cin>>pdone>>presult;
for(int i=0;i<n_size;i++){
n=arry[i].getcard();
if(n==m){
this->arry[i].setdone(pdone);
this->arry[i].setresult(presult);
}
}
}
int exist(string pcard){
int index=-1;
for(int i=0;in_size;i++){
if(this->arry[i]->getcard==pcard){
index=i;
break;
}
}
return index;
}
};
int main(){
return 0;
}

img

  • 写回答

1条回答 默认 最新

  • 浪客 2022-04-27 11:03
    关注

    arry[i]->getcard 里的getcard是函数要加括号

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月17日
  • 已采纳回答 9月9日
  • 创建了问题 4月27日

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值