#include <iostream>
#include <stdlib.h>
#include <string>
class namelist{
public :
namelist(){size=0;p=o;}
namelist(const string[],int);
namelist(const namelist&);
void set(const string &,int);
void set(const char*,int);
void dump()const;
private :
int size;
string *p;
void copyintop(const namelist&);
};
using namespace std;
namelist::namelist(const string s[],int s){
p=new string[size=s];
for(int i=0;i<size;i++)
p[i]=s[i];
}
namelist::namelist(const namelist&d){
p=0;
copyintop(d);
}
void namelist::copyintop(const namelist&d){
delete[]p;
if(d.p!=0){
p=nwe string[size=d.size];
for (int i=0;i<size;i++)
p[i]=d.p[i];
}
else{
p=0;
size=0;
}
}
void namelist::set(const string& s,int i){
p[i]=s;
}
void namelist::set(const char*s,int i){
p[i]=s;
}
void namelist::dump()const{
for(int i=0;i<size;i++)
cout<<p[i]<<endl;
}
int main(int argc, char *argv[])
{
string list[]={"lab","husky","collie"};
namelist d1(list,3);
d1.dump();
namelist d2(d1);
d2.dump();
d2.set("great dane",1);
d2.dump();
d1.dump();
return 0;
system("PAUSE");
return 0;
}
Error executing cl.exe.
namelist.exe - 21 error(s), 0 warning(s)