Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include <string.h>
- # include <stdlib.h>
- # include <stdio.h>
- using namespace std;
- class FORTA {
- double masa;
- double acceleratia;
- public:
- FORTA (): masa(0),acceleratia(0){};
- FORTA (double, double); // Primul constructor
- FORTA (FORTA &); // Al doilea constructor
- ~FORTA() { cout << "Trec prin destructor" << endl; }
- double get_masa()
- {
- return masa;
- }
- double get_acc()
- {
- return acceleratia;
- }
- void operator=(const FORTA &g)
- {
- masa=g.masa;
- acceleratia=g.acceleratia;
- }
- FORTA operator+(const FORTA &g)
- {
- FORTA h(masa + g.masa, acceleratia + g.acceleratia);
- return h;
- }
- };
- FORTA :: FORTA (double mm, double aa)
- {
- masa = mm;
- acceleratia = aa;
- cout << "Trec prin constructorul FORTA (double, double)" << endl;
- }
- FORTA :: FORTA (FORTA &g) // Constructor inþializator de forma C(C &)
- {
- masa = g.masa;
- acceleratia = g.acceleratia;
- cout << "Trec prin constructorul FORTA (FORTA &)" << endl;
- }
- void idle (FORTA f)
- {
- cout << "Sunt in functia idle()" << endl;
- }
- // Programul apelant
- int main ()
- {
- FORTA f1(10., 9.8);
- cout<<f1.get_masa()<<endl;
- cout<<f1.get_acc()<<endl;
- FORTA f2;
- f2 = f1;
- cout<<f2.get_masa()<<endl;
- cout<<f2.get_acc()<<endl;
- FORTA f3;
- f3=f1+f2;
- cout<<f3.get_masa()<<" "<<f3.get_acc()<<endl;
- idle(f2);
- // system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment