user2566506
user2566506

Reputation: 3

C++ error expected ' ' or '...' before numeric constant

Noob ask

void setName(const std::string& InkClient) { m_appName = InkClient; }
void setCompactName(const std::string& InkClient) { m_appCompactName = InkClient; }
void setVersion(const std::string& 0.1) { m_appVersion = 0.1 ; }

I dont know how i can fix

void setVersion(const std::string& 0.1) { m_appVersion = 0.1 ; }

Upvotes: 0

Views: 2283

Answers (1)

someone
someone

Reputation: 361

const std::string& 0.1

0.1 is actually a constant. A valid variable name is expected. If you don't need that argument for anything else, just remove it (leave brackets empty). If the function must take a parameter of type string by reference, just remove the constant. An argument with no name is not used by the function; however, it allows for dealing with compatibility issues. To keep the parameter usable, try the following:

void setVersion(const std::string& version) {m_appVersion = version;}

where version can be any valid variable name.

I hope this helps! :D

Upvotes: 4

Related Questions