Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class CRecentagle{//imamo razred Crecentagle
- private:
- int x,y; //do x in y nemoremo dostopati izven razreda
- public:
- void set_values (int a,int b);//varianta1 prototip metode, lahko bi bila kar tu kot varianta 2
- int area() {return (x*y);//varianta2, metoda je napisana kar v samem razredu
- }
- };
- void CRecentagle::set_values(int a,int b){
- x=a;
- y=b;
- }
- int main(){
- CRecentagle rect;
- rect.set_values(3,4);
- cout<<"ploscina: "<<rect.area()<<endl;
- //ce jo poklicemo
- //pred set.value() dobimo neko vrednost iz polnilnika
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement