I'm just learning C++ in a class I'm taking in college, but I have had Java. How do I declare varibles Such as (float, integer, double, char and Bol.??
Please help!!
Thanks
I'm just learning C++ in a class I'm taking in college, but I have had Java. How do I declare varibles Such as (float, integer, double, char and Bol.??
Please help!!
Thanks
Like so
Code:int a=3; float length=0.34;
thought it was the same as java.
Code:float number = 12.34f; double number2 = 12.3456; int number3 = 12; char name[] = "Hello"; bool loop(true);
Never seen a bool declared like that ever.Originally posted by laasunde
Code:bool loop(true);
Just to be sure use this.
Code:bool loop=true;
these things should be included in the first lesson!
I'm just learning C++ in a class I'm taking in college, but I have had Java. How do I declare varibles Such as (float, integer, double, char and Bol.??
please leave the name of the college and the name of your teacher so others dont make the same misstake!
>>Never seen a bool declared like that ever.
All types have a constructor, even built in types. So you can use the initialization value as a constructor argument:
and the functionality is equivalent toCode:int a(10); bool loop(true);
:-)Code:int a = 10; bool loop = true;
*Cela*
You can declare a string two ways :Originally posted by Travis Dane
Never seen a bool declared like that ever.
Just to be sure use this.
Code:bool loop=true;
by the same token I thought you could declare bool :Code:string name = "john"; string name2("john");
Works fine on my computer anywayCode:bool x=true; bool y(true);