Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class CRecentagle{//imamo razred Crecentagle
  5. private:
  6. int x,y; //do x in y nemoremo dostopati izven razreda
  7. public:
  8. void set_values (int a,int b);//varianta1 prototip metode, lahko bi bila kar tu kot varianta 2
  9.  
  10.  
  11. int area() {return (x*y);//varianta2, metoda je napisana kar v samem razredu
  12. }
  13. };
  14.  
  15.  
  16.  
  17.  
  18. void CRecentagle::set_values(int a,int b){
  19. x=a;
  20. y=b;
  21. }
  22.  
  23.  
  24.  
  25. int main(){
  26. CRecentagle rect;
  27. rect.set_values(3,4);
  28. cout<<"ploscina: "<<rect.area()<<endl;
  29. //ce jo poklicemo
  30. //pred set.value() dobimo neko vrednost iz polnilnika
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement