1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include "stdafx.h"
#include <string.h>
#include <stdio.h>
class client{
public:
client();
client(const client & evo);
client(char * nom,int age,int code);
client::~client();
protected:
char *_nom;
int age;
int code;
};
client::client(){
this->_nom =0;
}
client::client(char *nom,int age,int code){
this->_nom =new char[strlen(nom)+1];
strcpy(nom,this->_nom);
this->age =age;
this->code =code;
}
client::~client()
{
if (_nom)
delete [] _nom;
}
int main(int argc, char* argv[])
{
client c();
client a("dotnet",5,32);
client b(a);
client *d;
d=new client(b);
delete d;
return 0;
} |
Partager