Better307 2022-06-10 19:41 采纳率: 33.3%
浏览 17

这个为什么会这样,应该要怎么解决

为什么会显示没有匹配

#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstring>
using namespace std;
class AddressBook{
public:
  AddressBook(char* n, char* p, char* h);
  virtual void Display(ostream& out);
protected:
  char name[20];
  char phone[10];
  char handp[15];
};
AddressBook::AddressBook(char*n,char* p,char* h){
  strncpy_s(name, n, 19);  name[19]=0;
  strncpy_s(phone, p, 9);  phone[9]=0;
  strncpy_s(handp, h, 14); handp[14]=0;
}
void AddressBook::Display(ostream& out){
  out<<setiosflags(ios::left)<<setw(20)<<name
         <<setw(10)<<phone<<setw(15)<<handp<<endl;
}
ostream& operator<<(ostream& out, AddressBook& a){
  a.Display(out);
  return out;
}
int main(){
  AddressBook a1("Dill Arnson", "8869533", "13902201080");
  AddressBook a2("Welch Shammas", "6695482", "13023399001");
  AddressBook a3("Portel Braumbel", "5937221","13908032991");

  cout<<a1;
  cout<<a2;
  cout<<a3;
}

img

  • 写回答

2条回答 默认 最新

  • 在黎明的反思 2022-06-10 20:43
    关注

    AddressBook(const char* n, const char* p,const char* h);改成这样试试

    评论

报告相同问题?

问题事件

  • 创建了问题 6月10日

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?