N
Norden26
Надо добавить экземпляр класса Abonent в вектор book.
C++:
#include <iostream>
#include <vector>
typedef unsigned short ushort;
using namespace std;
class Abonent
{
public:
Abonent()
{
this->name = NULL;
this->number = 0;
}
Abonent(const char * name, ushort number)
{
this->name = strcpy(new char [strlen(name)+1], name);
this->number = number;
}
~Abonent()
{
if(name)
delete name;
}
void print()
{
cout<<this->name<<" "<<this->number<<endl;
}
private:
char * name;
ushort number;
};
void main()
{
Abonent abonent0("Vasia", 123);
vector <Abonent> book; // vector
vector <Abonent>::iterator it = book.begin();
book.insert(it, abonent0);
}