#include <iostream>
using namespace std;
#include <cstring>
class Naytto
{
char koko[10];
public:
Naytto(const char p_koko[]) {strcpy(koko, p_koko);}
~Naytto() {strcpy(koko, " ");}
void Nayta() const {cout<<"\nNäytön koko: "<<koko;}
};
class Keskusyksikko
{
char muistia[10];
public:
Keskusyksikko(const char p_muisti[]) {strcpy(muistia,p_muisti);}
~Keskusyksikko() {strcpy(muistia, " ");}
void Nayta() const {cout<<"\nKeskusmuistia:"<<muistia;}
};
class Tietokone
{
char merkki[25];
Keskusyksikko &CPU;
Naytto *naytto;
public:
Tietokone(const char [], const char [], const char []);
Tietokone(const Tietokone &);
~Tietokone();
Tietokone &operator=(const Tietokone &);
void Nayta() const;
Naytto *IrrotaNaytto();
void LiitaNaytto(Naytto *);
};
Tietokone::Tietokone(const char p_merkki[], const charp_cpu[], const char p_naytto[]):
CPU(*(new Keskusyksikko(p_cpu)))
{
strcpy(merkki, p_merkki);
naytto = new Naytto(p_naytto);
}
Tietokone::Tietokone(const Tietokone &P_kone)
: CPU(*(new Keskusyksikko(P_kone.CPU)))
{
strcpy(merkki, P_kone.merkki);
if (P_kone.naytto)
naytto = new Naytto(*(P_kone.naytto));
else
naytto = NULL;
}
Tietokone &Tietokone::operator=(const Tietokone &P_kone)
{
if (this == &P_kone) return (*this);
strcpy(merkki, P_kone.merkki);
CPU = P_kone.CPU;
if (!P_kone.naytto)
naytto = new Naytto(*(P_kone.naytto));
else
*naytto = *P_kone.naytto;
return (*this);
}