Reputation: 11
How do i declare a variable having spaces like the one below
std::string First Name="harry";
in visual studio 2010 it shows error this declaration has no storage or class specified.
Upvotes: 0
Views: 489
Reputation: 4933
You can not have variable names with spaces. So you have to define them using underscore or use caps as below.
std::string First_Name="harry";
std::string FirstName="harry";
Upvotes: 1
Reputation: 521914
You cannot have variable names containing whitespace. In fact, white space is what the compiler uses to determine when a variable name, literal, operator, etc., begins and another one ends.
As @DevT mentioned in his comment, one option for simulating whitespace in variable names is to use underscores instead. So you could try the following:
std::string First_Name = "harry";
Upvotes: 3