HI, i just latelly started with Object Oriented programming in c++ and i have a simple question... well, i have a square for which i put in the x and y, but then i have a method that should change the x and y, but somehow that doesnt happen, and i have been breaking my head to figure it out why not...
here is my code:
here is my code:
Code:
#include <iostream>
using namespace std;
class aabbcc{
private:
int x,y;
public:
void setxy(int a, int b){
x=a;
y=b;
}
int sqxy(){
return x*y;
}
void change(int proc){
x=x+((x/100)*proc);
y=y+((y/100)*proc);
}
void print(){
cout << "X and Y" <<"(" << x << ", " << y << ")" << endl;
}
};
int main(){
aabbcc green;
green.setxy(10,5);
cout << "x*y: " << green.sqxy() << endl;
green. print();
green.change(20);
cout << "Changed: " << green.sqxy() << endl;
green.print();
system("PAUSE");
return 0;
}