Está en la página 1de 4

#include<iostream>

#include<fstream>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<map>
#include<vector>
using namespace std;
//clasa de baza
class Motor{
private:
char* nrInmatriculare;
char serieMotor[16];
int capacitate;
public:
//get-eri si set-eri
char* get_nrInmatriculare(){
return nrInmatriculare;
}
char* get_serieMotor(){
return serieMotor;
}
int get_capacitate(){
return capacitate;
}
void set_nrInmatriculare(char* nrInmatriculare){
this->nrInmatriculare = new char[strlen(nrInmatriculare) + 1];
strcpy(this->nrInmatriculare, nrInmatriculare);
}
void set_serieMotor(char* serieMotor){
strcpy(this->serieMotor, serieMotor);
}
void set_capacitate(int capacitate){
this->capacitate = capacitate;
}
//const fara param
Motor() {
this->nrInmatriculare = new char[strlen("ion")];
strcpy(this->nrInmatriculare, "ion");
strcpy(this->serieMotor, "seriemot");
capacitate = 10;
}
//const cu param

Motor(char* z, char* x, int y){


this->nrInmatriculare = new char[strlen(z) + 1];
strcpy(this->nrInmatriculare, z);
strcpy(this->serieMotor, x);
this->capacitate = y;
}
//const de copiere
Motor(Motor& a){
this->nrInmatriculare = new char[strlen(a.nrInmatriculare) + 1];
strcpy(this->nrInmatriculare, a.nrInmatriculare);
strcpy(this->serieMotor, a.serieMotor);
this->capacitate = a.capacitate;
}
//operator =
Motor&operator=(Motor&a){
this->nrInmatriculare = new char[strlen(a.nrInmatriculare) + 1];
strcpy(this->nrInmatriculare, a.nrInmatriculare);
strcpy(this->serieMotor, a.serieMotor);
this->capacitate = a.capacitate;
return*this;
}
//destructor
~Motor(){
if (this->nrInmatriculare != NULL)
delete this->nrInmatriculare;
}

};
//clasa derivata
class SnowMobil: public Motor
{
private:
char* idPermis;
float pretPerOra;
int nrOreInchiriere;
public:
//get-eri si set-eri
char* get_idPermis(){
return idPermis;
}
float get_pretPerOra(){

return pretPerOra;
}
int get_nrOreInchiriere(){
return nrOreInchiriere;
}
void set_idPermis(char* idPermis){
this->idPermis = new char[strlen(idPermis) + 1];
strcpy(this->idPermis, idPermis);
}
void set_pretPerOra(float pretPerOra){
this->pretPerOra = pretPerOra;
}
void set_nrOreInchiriate(int nrOreInchiriere){
this->nrOreInchiriere = nrOreInchiriere;
}
//const fara param
SnowMobil (): Motor () {
this->idPermis = new char[strlen("sn")];
strcpy(this->idPermis, "sn");
this->pretPerOra = 2.0;
this->nrOreInchiriere = 2;
}
//const cu param
SnowMobil(char* a, char*b, int c, char* d, float e, int f) :Motor(a, b,
c){
this->idPermis = new char[strlen(d) + 1];
strcpy(idPermis, d);
this->pretPerOra = e;
this->nrOreInchiriere = f;
}
//const de copiere
SnowMobil(SnowMobil&a) :Motor(a){
this->idPermis = new char[strlen(a.idPermis) + 1];
strcpy(this->idPermis, a.idPermis);
this->pretPerOra = a.pretPerOra;
this->nrOreInchiriere = a.nrOreInchiriere;
}
//operator =
SnowMobil&operator=(const SnowMobil&a){
this->idPermis = new char[strlen(a.idPermis) + 1];
strcpy(this->idPermis, a.idPermis);
this->pretPerOra = a.pretPerOra;
this->nrOreInchiriere = a.nrOreInchiriere;
return*this;
}
//destructor pt clasa derivata
~SnowMobil(){
if (this->idPermis != NULL)

delete this->idPermis;
}

};
void main(){
SnowMobil a1;
cout << a1.get_idPermis() << endl;
cout << a1.get_pretPerOra() << endl;
}

También podría gustarte