You are on page 1of 2

1 /******************************************************************************

2
3 Online C++ Compiler.
4 Code, Compile, Run and Debug C++ program online.
5 Write your code in this editor and press "Run" button to compile and execute it.
6
7 *******************************************************************************/
8 #include <iostream>
9
10 using namespace std;
11 class Dvizenje{
12 private: float s,v,t;
13 public:
14 Dvizenje(){//konstruktor bez parametri se koristi za inicijalizacija
15
16 cout<<"\n Konstruktor ";
17 s=101; v=5; t=7;}
18 Dvizenje( float s, float v, float tt){ // konstruktor so 1 parametar ;
19 cout<<"\n Konstruktor ";
20 this->s=s;
21 this->v=v;
22 t=tt;
23 }
24 ~Dvizenje(){ cout<<"\n Destruktor";} // destruktor - ja osloboduva memorijata koja ja zafatila klasata
25
26 float pat(){return v*t;}
27 float brzina(){ return s/t;}
28 float vreme(){ return s/v;}
29
30 void zapisS(float ss) {s=ss;}
31 float dajS() const{ return s;}
32
33 };
34
35 int main()
36 {
37 Dvizenje Start;
38 cout<<"Patot e: "<< Start.pat()<<endl;
39 cout<<"Vremeto e: "<< Start.vreme()<<endl;
40 cout<<"Brzinata e: "<< Start.brzina()<<endl;
41
42
43 Dvizenje *St=new Dvizenje; // Dvizenje st;
44
45 cout<<"Patot e: "<< St->pat()<<endl;
46 cout<<"Vremeto e: "<< St->vreme()<<endl;
47 cout<<"Brzinata e: "<< St->brzina()<<endl;
48 delete St;
49 return 0;
50 }
51
52
53 /*
54
55 // dinamicki definirana klasa
56 Kocka *dkoc=new Kocka();
57 cout<<"Plostinata e> "<< dkoc ->plostina()<<endl;
58 cout<<"Volumenot e> "<< dkoc->volumen()<<endl;
59
60 delete dkoc;
61
62 // ????????? ?????????? ????? ?? ??????????? ?? ?????????
63 cout<< " Vnesi aa ";
64 cin>>aa;
65 Kocka *dkoc2=new Kocka(aa);
66 cout<<"Plostinata e> "<< dkoc2 ->plostina()<<endl;
67 cout<<"Volumenot e> "<< dkoc2->volumen()<<endl;
68
69 delete dkoc2;
70
71 */
72 return 0;
73 }

You might also like