Page 1 of 1

c++ Variables

Posted: Wed Dec 23, 2009 7:04 pm
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

Re: c++ Variables

Posted: Wed Dec 23, 2009 10:56 pm
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.
}

Re: c++ Variables

Posted: Thu Dec 24, 2009 2:00 am
by ZeroComp
Sorry, I was trying to do this off of very vague memory :oops: