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:
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;
}
Ok, thank you. Is there a way i can just change the type int to doulbe just inside of that change and sqxy methods so i can still use an integer as input and all
well, ye, i know that, but a got a book from the library, and i has some exercieses but not the solutions... :/ and it says i have to keep x andy as integers, and add to their values for a certain %, so if the x is 100 and %=20, it should return 120... but it becomes tricky when the numbers are decimal...
ofc. just change the type of x and y in your class.
however, if you want to use ints you may need to add some casts, to avoid compiler precision loss warnings.
EDIT:
im slow as always.
following will do:
Code:
x += (int) (x * proc / 100.0f); // Use c++ style casts for free internetz
y += (int) (y * proc / 100.0f);
EDIT2:
if you dont want to use any floats use following:
yes, i tried this, but the results are not correct as it rounds up some decimals and gives me full numbers... :/ i would use double, but as said the exercise requires me to put in both sides of square (x & y) as int, and then change their length for a certain % which may result in decimal values (double) :/
Beginner's question 12/04/2012 - SRO Private Server - 2 Replies Hey guys, I have a little question for you.
I finally decided to start learning about pk2 editing and all that. I downloaded pushedx pk2 exporter and everything. Now, I used Cherno's tool for finding a blowfish key and it gave me 169841. Now, I tried everything, converted it to hex (tried like 2-3 different methods), just typing 169841, and countless other things, and nothing works. It was still a wrong password.
So my question is: What's the real password? I just want to mess around with...
Beginner Gold premium question 03/31/2010 - Silkroad Online - 12 Replies Well im about to buy it, so, is the premium 150% xp/sp 28 days? and preferred game login?
what else you know about it?
ty in advance, diogo
Beginner BOT question 07/06/2009 - World of Warcraft - 0 Replies Hey everyone,
I have been playing WoW off and on for a couple of years now and was thinking of getting back into it again. I do remember the constant grinding to gain levels so this time around i was thinking of perhaps using a bot to do the dirty work for me.
My question is mainly how safe they are and in which way they can be used to minimize the chance of being detected?
I was actually planning on letting the bot do its thing while i basically sit by the computer doing other things...
Beginner CE question.. 04/17/2008 - Cabal Online - 9 Replies Oi! Eversince i started playing cabal i've been playing with ProjectX, Sora Engine and Cheat engine 5.4... However, i can't get much to work.. Only a few hacks.
I run Cabal Europe, with GG emuserver coded by Pyte, OS: Windows Vista. I once got the walkspeed hack to work, but after that, nothing. After a while not even the walkspeed hack anymore.
When i run a cheat engine (Mostly Sora Engine), and i click the process list, i can't see CABAL. Only in the "window list". Is this normal? I think...