samedi 21 mars 2020

How to define a function that returns a string outside a struct it was declared in

I am having trouble getting my code to work, and not sure how to solve this problem.

#include <string>
struct car{
std::string car_name;
std::string get_name(void);
};

car::std::string get_name(){
return car_name;
}

Gives me error " error: 'std' in 'struct car' does not name a type car::std::string get_name(void)"

Aucun commentaire:

Enregistrer un commentaire