Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable:4996)
- #include<iostream>
- #include<conio.h>
- #include<stdio.h>
- #include<stdlib.h>
- using namespace std;
- class telefon {
- protected:
- int nr;
- char NumeOperator[100];
- public:
- telefon() {
- }
- telefon(int nr, char numeOperator[]);
- ~telefon();
- telefon(telefon& v);
- int getNr();
- char *getNume();
- void setNr(int nr);
- void setNume(char nume[]);
- void citire();
- virtual void afisare();
- };
- telefon::telefon(int nr, char numeOperator[]) {
- this->nr = nr;
- strcpy(this->NumeOperator, numeOperator);
- }
- telefon::~telefon() {
- cout << "S-a apelat destructorul";
- }
- telefon::telefon(telefon& v) {
- this->nr = v.nr;
- strcpy(this->NumeOperator, v.NumeOperator);
- }
- int telefon::getNr() {
- return this->nr;
- }
- char *telefon::getNume() {
- return this->NumeOperator;
- }
- void telefon::setNr(int nr) {
- this->nr = nr;
- }
- void telefon::setNume(char nume[]) {
- strcpy(this->NumeOperator, nume);
- }
- void telefon::citire() {
- cout << "\nNumar = ";
- cin >> this->nr;
- cout << "Nume Operator = ";
- gets_s(this->NumeOperator);
- }
- void telefon::afisare() {
- cout << "\n---------------\n Afisare din clasa de baza telefon:\n";
- cout << "\nNumar = " << this->nr << endl;
- cout << "\nNume Operator = " << this->NumeOperator << endl;
- }
- class telefonMobil : public telefon {
- protected:
- int autonomie;
- public:
- telefonMobil(int autonomie, int nr, char NumeOperator[]) :telefon(nr, NumeOperator) {
- this->autonomie = autonomie;
- }
- ~telefonMobil() {
- cout << "\nS-a apelat destructorul\n";
- }
- telefonMobil(telefonMobil& n) :telefon(n) {
- this->autonomie = n.autonomie;
- }
- int getautonomie() {
- return this->autonomie;
- }
- int setautonomie(int autonomie) {
- this->autonomie = autonomie;
- }
- void citire() {
- this->telefon::citire();
- cout << "\nautonomie = "; cin >> this->autonomie;
- }
- void afisare() {
- this->telefon::afisare();
- cout << "\nautonomie = " << this->autonomie;
- }
- };
- void main() {
- // telefon nokia();
- //telefon nokia(1, "asd");
- telefonMobil test(1,10,"testare");
- test.afisare();
- telefon *pointer;
- pointer = new telefon;
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement