Prikazi cijelu temu 22.02.2014 20:53
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Primjer Klase
PreuzmiIzvorni kôd (C++):
  1. #include <conio.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class kugla
  6. {
  7.       private:// float r;
  8.      
  9.       public: float r;
  10.               float Opseg()
  11.               {
  12.                    return r*r;
  13.               }
  14.              
  15.               float Povrsina()
  16.               {
  17.                     return 4*r*r*3.14;
  18.                    
  19.               }
  20.              
  21.               kugla (float x)  {r=x;}
  22.               kugla () {r=1;}
  23.              
  24.       };
  25.      
  26. int main()
  27. {
  28. kugla A(2);
  29. kugla B;
  30. kugla C(4);
  31.  
  32. cout<<A.Opseg()<<endl;
  33. cout<<A.Povrsina()<<endl<<endl;
  34.  
  35. cout<<B.Opseg()<<endl;
  36. cout<<B.Povrsina()<<endl;
  37.  
  38. cout<<C.Opseg()<<endl;
  39. cout<<C.Povrsina()<<endl;
  40.  
  41.  
  42. getch();    
  43. }

Podrška samo putem foruma, jer samo tako i ostali imaju koristi od toga.