Home > Back-end >  How do I will be the main objects in the array chu 'shi hua to another array of objects in the
How do I will be the main objects in the array chu 'shi hua to another array of objects in the

Time:10-01

#include
using namespace std;

The class Person
{
Const string idNum;
String name;
String * tel;
String qq;
String weixin.
String address;

Public:
The Person () {}
The Person (string idnum, string pname, string * ptel, string PQQ, string pweixin, string paddress) : idnum (idnum)
{
Name=pname.
String * p=ptel;
Int iLen=0;
While (p [iLen]!="")
{
ILen++;
//* p++;
P++;
//+;
}
Tel=new string [iLen + 1];
for (int i=0; I & lt; ILen + 1; I++)
{
Tel [I]=ptel [I];
//cout

//cout}
Qq=PQQ;
Weixin=pweixin;
Address=paddress;
}
The Person (const Person & amp; Q) : idNum (q.i dNum)
{
Name=q.n ame.
String * p=tel;
Int iLen=0;
While (p [iLen]!="")
{
ILen++;
//* p++;
P++;
//+;
}
for (int i=0; I & lt; ILen; I++)
{
=q.t el tel [I] [I];
}
Qq=q.q q;
Weixin=q.w eixin;
Address=q.a ddress.
}

Void elegantly-named setName (string name)
{
This - & gt; Name=name;
}
String getName ()
{
Return this - & gt; name;
}
Void setQQ (string QQ)
{
Qq=qq;
}
String getQQ ()
{
Return this - & gt; Qq;
}
Void setweixin (string weixin)
{
This - & gt; Weixin=weixin;
}
String getweixin ()
{
Return this - & gt; Weixin.
}
Void setaddress (string address)
{
This - & gt; Address=address;
}
String getaddress ()
{
The return address.
}

Void setTel (string * tel)
{
String * p=tel;
Int n=0;
While (p [n].="")
{
N++;
P++;
}
for (int i=0; I & lt; n; I++)
{
This - & gt; Tel [I]=tel [I];
}
delete p;
}
String * getTel ()
{
Return tel;
}
Void the toString ()
{
Cout & lt; String * p=tel;
Int iLen=0;
While (p [iLen]!="")
{
ILen++;
//* p++;
P++;
//+;
}
for (int i=0; I & lt; ILen; I++)
{
Cout & lt; }
Cout & lt; delete p;
}
};
The class expressions such as AddressList
{
Private:
* per Person;
int count;//contact number
Int capacity;//capacity
Public:
Expressions such as AddressList (Person * p, int n, int m)/a/n:
m: number of capacity{

Per=new Person [m].
for(int i=0; I{
=p per [I] [I];//an error, could you tell me how to get the Person array assignment to the members of the expressions such as Addresslist object per?
//per [I] (* (p [I]));
}

The count=n;
Capacity=m;
}
//add contacts (increase) in the tail
//void addPerson (Person) p {


//}
Void pp ()
{
Per [0]. ToString ();
}
};


Int main ()
{
Const string idNum="111111111111111";//not considering the situation of digits right
String name="aaa";
String tel [100]={" 2222222222 ", "333333333333"};
String qq="44444444444444";
String weixin="5555555555555555";
String address="China";
The Person p1 (idNum, name, tel, qq, weixin, address).
//cout
Person p [2]={(Person (idNum, name, tel, qq, weixin, address), the Person (idNum, name, tel, qq, weixin, address))};
Expressions such as AddressList add (p, 2100);
The add. Pp ();





}

  • Related