Hello guys,
I'm learning c++ and I'm trying to implement it on the correct way.
However, I found different approachs, and sometimes with opposite directions.
I'm using this "standard" class implemention, which is described on the c++ annotations .
Code:
#include <string>
class Person
{
std::string d_name; // name of person
std::string d_address; // address field
std::string d_phone; // telephone number
size_t d_mass; // the mass in kg.
public: // member functions
void setName(std::string const &name);
void setAddress(std::string const &address);
void setPhone(std::string const &phone);
void setMass(size_t mass);
std::string const &name() const;
std::string const &address() const;
std::string const &phone() const;
size_t mass() const;
};
Of course, that I'm using namespace std , but I follow this "prescription".
What do you think about it? Is it worthing?
Should I use string const with a pointer or simply use the string type passing values instead of references?
Do I really need set_variables? Probably this turns everything more difficult when I'll try to handle a different type of constructor (like I describe in this post Constructors and Conditionals)