主函数调用 txl 的构造函数时直接报错,构造不了
//txl.h
#pragma once
#include<iostream>
using namespace std;
class phone
{
private:
string name;
string number;
friend class txl;
public:
string getname() const{ return name; }
string getnum() const{ return number; }
void show()const;
phone(const string names = 0, const string numbers = 0) :name(names), number(numbers) {}
phone(phone& p) :name(p.name), number(p.number) {}
phone& operator =(phone&);
};
class txl
{
private:
phone txll[100];
int total;
public:
void add(phone& p);
void show()const;
bool search(const string& p)const;
bool change(const int& p);
txl(phone& p)
{
total = 1;
txll[total] = p;
total++;
}
txl()
{
total = 1;
}
};
#include<iostream>
#include"txl.h"
using namespace std;
int main()
{
phone pp("zmas", "123456");
phone pm=pp;
txl abc(pp);//就是这里直接报错
phone pc("szzz", "564565");
phone pa("ssss", "485665");
phone pd("znnd", "485645");
abc.add(pp); abc.add(pc); abc.add(pa); abc.add(pd);
cout << abc.search("szzz");
cout<<abc.search("smasmdassdyuas");
abc.change(3);
abc.show();
}