c++ Variables

C++, C#, Java, PHP, ect...
Post Reply
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

c++ Variables

Post by ZeroComp »

Heres a simple variable production for C+

Code: Select all

#include<iostream.h>
int main()
myName
myWeapon
myAmmo
myItems
now you just access them and add things. to increase ammo capacity by 1 persay you just say myAmmo++
but for myWeapon you can add things under the class 'Weapon' and for name class'Name'
and the same with items
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: c++ Variables

Post by Falken »

ZeroComp wrote:Heres a simple variable production for C+

Code: Select all

#include<iostream.h>
int main()
myName
myWeapon
myAmmo
myItems
now you just access them and add things. to increase ammo capacity by 1 persay you just say myAmmo++
but for myWeapon you can add things under the class 'Weapon' and for name class'Name'
and the same with items

You forgot the { and } you also have to set what type of variable. And no need to include iostream unless you want to print something on the screen or take input from the user. Often a good idea to set values at start too, else weird things might happen if you are unlucky and may cause very strange bugs.

should be:

Code: Select all

int main()
{
   int health = 100; // A number
   float mana = 99.5; // A decimal number, can also use double, differs in how many decimals.
   bool alive = true; // True or false value
   char symbol = 'a'; // A single character.
}
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
ZeroComp
Posts: 648
Joined: Thu Oct 29, 2009 8:48 pm

Re: c++ Variables

Post by ZeroComp »

Sorry, I was trying to do this off of very vague memory :oops:
Coding-PHP, Javascript, C++, HTML, mySQL
Modeling/Art-Blender, GIMP
Games-Unity, Game Maker 8
Post Reply

Return to “Coding”