-
Posts
1,661 -
Joined
-
Last visited
Content Type
Profiles
Events
Forums
Blogs
Downloads
Everything posted by someboddy
-
916 ft. My height record was 183 ft, so it might be a new record
-
Nice movie, even altough I am not in it. Well, at least my a$s is not getting kicked...
-
Tutorial-the basics of C++ and game making
someboddy replied to someboddy's topic in Gossip Café [/offtopic]
Well, I studied the substring a little more, and it seems that there is a major diffreance between SubString and char. SubString represents a part of an actual String, so if you change the SubString, the String will change as well. If you want to convert a char to a SubString, write this simple class: class CharMadeSubString:public SubString { private: String sourceString; public: CharMadeSubString(char ch) { sourceString=ch; SubString(sourceString,0,1); } }; You can put it in an header file if you know how. I didn't tested the code, so if there is a problem, just tell me. It will not act like a normal SubString, but you will be able to use it with functions require SubString. If you don't understand some of the code, just write it, and use it like a function, like "CharMadeSubString('a')". I will probebly get to it later on, and so will your teacher. -
Tutorial-the basics of C++ and game making
someboddy replied to someboddy's topic in Gossip Café [/offtopic]
You don't use substrings instead of chars. You still use chars if you want a single char. Substrings represent parts of strings which can have more then a single char. -
His house looks like a store.
-
Is there such a program?
-
GBA XBox Tamaguchi
-
Because not everybody have a PS2
-
Sure. There is a machine just outside my house which sells them for 10$... Get a PS2 he says...
-
Well, I downloaded Star Wars Starfighter Speciel Edition for my Xbox. After I copied it to my hard-drive started it, it had rendering problems like some of the N64 games runing on N64 emulator : surfaces missing and stuff. WTF???
-
Dead or Alive 3 Dead or Alive Ultimate Morrowind(get game of the year edition) Crimson Skies Thief 3 And I think this thread belongs to the XBox section.
-
A spiked club.
-
Tutorial-the basics of C++ and game making
someboddy replied to someboddy's topic in Gossip Café [/offtopic]
Operator overloading is one of my favorite things in C++. JAVA doesn't have it, and therefore JAVA sucks. well, JAVA isn't realy sucks, but it's a shame it doesn't have operator overloading. So what is operator overloading? lets take this 'Point' class: class Point { private: int x,y; public: void setx(int nx) { x=nx; } void sety(int ny) { y=ny; } Point() { x=0; y=0; } Point(int nx,int ny) { x=nx; y=ny; } int getx() { return x; } int gety() { return y; } }; Wouldn't it be nice that if we have: Point a(1,3),b(5,2); we could write "a+b" and get the point (6,5)? Well, we can do it with C++, using operator overloading. There are two ways of doing it. The first way is to use a global function: Point operator+(Point p1,Point p2) { return Point(p1.getx()+p2.getx(),p1.gety()+p2.gety()); } When we name a function "operator#" when # can be any C\C++ operator exept.,->,new,delete,sizeof and (VariableType). VariableType can be reaplaced with float, char, or any other type. The second way is to declare the operator function inside a class. In that way, you only need one argument. The first operand will be the object itself: class Point { private: int x,y; public: void setx(int nx) { x=nx; } void sety(int ny) { y=ny; } Point() { x=0; y=0; } Point(int nx,int ny) { x=nx; y=ny; } int getx() { return x; } int gety() { return y; } Point operator+(Point p) { return Point(x+p.x,y+p.y) } }; Here, we don't use getx and gety, because a function inside a class can access the private members of any class of that kind, not just of the object "this". You can also overload onary operators - operators that recive only one operand, like "x++" or "-d". So how do you do it? Overloading "+x","-x","++x" and "--x" is very simple: if you do it as a class function, you need to send no arguments to the operator function: Point operator-() { return Point(-x,-y); } Overloading "x++" and "x--" is a litle more complax. You need to add a dummy int argument to the function, that will act like the second operand - which doesn'y exist, so it's blank. Lets say that for the point p, "p++" adds 1 to both x and y: Point operator++(int) { Point tmp=this; ++x; ++y; return tmp; } Note two things: 1. We stored the current Point in tmp, because the "x++" operator returns the value of x before the addding action. 2. The operator = is automaticly overloaded for any user declared class. It simply copies all of one objects data to another. You can overload this operator if you want, for example, if your class uses pointers: class String { private: char str[20]; public: String(int length) { } void operator=(String s) { for(int i=0;i<20;i++) str[i]=s.str[i]; } }; This String class is just an example. We will write a better one later. Before we go on, I will need to explain a very usefull thing about functions: If you put '&' before an argument, it will be send by referance, meaning the function will be able to actualy change it's value: #include<iostream.h> void valswap(int a,int b) { int tmp=a; a=b; b=tmp; } void refswap(int &a,int &b) { int tmp=a; a=b; b=tmp; } void main() { int a=4,b=6; valswap(a,b); cout<<"swapping by value: a="<<a<<",b="<<b; refswap(a,b); cout<<"\nswapping by referance: a="<<a<<",b="<<b; } The output will be: swapping by value: a=4,b=6 swapping by referance: a=6,b=4 you can also put the '&' before the function name, so the function will refer to an actual variable, and you will be able to change that variable: void &max(int &a,int &b) { if(a>b) return a; return b; } Now you can write "max(x,y)=8", and the bigger between the two variables will be set to 8. Now lets go on to the index operator. Lets overload an index operator to our String class: class String { private: char str[20]; public: String(int length) { } void operator=(String s) { for(int i=0;i<20;i++) str[i]=s.str[i]; } char &operator[](int loc) { return str[loc]; } }; The argument (the second argument when used outside of a class), is the number between '[' and ']'. Now we can access the variables inside our String objects just like a normal string - a char array. That will be all for today. Class dismissed. -
Is there such a program or bios or something?
-
You have insulted the XBox controller. Perpare to meet you doom!!!
-
Haha... may I ask what move it was? <{POST_SNAPBACK}> Soriuken(qcf+punch whith ryu/ken/akuma/dan)
-
Only if you live in tailand. Are rabbits wondering in the streets where you live?
-
Well, it looks like I was lucky. I have only done a Streer Fighter move on my friend and hurt my finger.
-
S.O.M.E.B.O.D.D.Y.: Synthetic Obedient Machine Engineered for Battle/Organism Designed for Destruction and Yelling
-
Click here Never tought you can do it with a boat.
-
If kids won't buy games, the game companies will earn less money. If the game companies will earn less money, they will make less games. If the game companies will will make less games, I will be very very mad.
-
Games can affact people. Only a week ago I ran around the town, jumping on turtels, eating mushrooms and entering sewer pipes. Seriously, this has been said before, it will be said again, and I don't care if shops won't sell me games becaues I am under 18, it will only give me another acsuse to use P2P.
-
I downloaded an ISO in RAR format via bittorrent, but it had a password. In the readme it was writen to go to an IRC channel for the password, but the channel is offline, and so is the site mentioned in the readme. So my question is: is there a way to hack that RAR?