50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
//name.cpp
|
|
|
|
#ifndef __NAME_CPP__
|
|
|
|
#define __NAME_CPP__
|
|
|
|
#include <iostream.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "name.h"
|
|
|
|
//##################################################
|
|
|
|
// Name
|
|
|
|
// Puts name into a buffer
|
|
|
|
//==================================================
|
|
|
|
Name::Name(char *txt) {
|
|
|
|
buff = new char[strlen(txt) + 1];
|
|
|
|
strcpy(buff, txt);
|
|
|
|
}
|
|
|
|
//##################################################
|
|
|
|
// Destructor
|
|
|
|
// Delets buffer
|
|
|
|
//==================================================
|
|
|
|
Name::~Name() {
|
|
|
|
delete [] buff;
|
|
|
|
}
|
|
|
|
//##################################################
|
|
|
|
// Operator overload
|
|
|
|
// Deletes buffer and makes a new one
|
|
|
|
// and copies the data
|
|
|
|
//==================================================
|
|
|
|
void Name::operator = (const Name &src) {
|
|
|
|
delete [] buff;
|
|
|
|
buff = new char[strlen(src.buff) + 1];
|
|
|
|
strcpy(buff, src.buff);
|
|
|
|
}
|
|
|
|
//##################################################
|
|
|
|
// Constructor
|
|
|
|
// Creates a new name
|
|
|
|
//==================================================
|
|
|
|
Name::Name(const Name &src) {
|
|
|
|
buff = new char[strlen(src.buff) + 1];
|
|
|
|
strcpy(buff, src.buff);
|
|
|
|
}
|
|
|
|
//##################################################
|
|
|
|
// Print
|
|
|
|
// Prints out a name
|
|
|
|
//==================================================
|
|
|
|
void Name::print() {
|
|
|
|
cout << buff;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|