default parameters c++ constructors


is good use have category constructor uses default parameters, should i removed overloaded constructors? example:



// this...
class foo
{
private:
std::string name_;
unsigned int age_;
public:
foo(const std::string& name = "", const unsigned int age = 0) :
name_(name),
age_(age)
{
...
}
};

// this?
class foo
{
private:
std::string name_;
unsigned int age_;
public:
foo() :
name_(""),
age_(0)
{
}

foo(const std::string& name, const unsigned int age) :
name_(name),
age_(age)
{
...
}
};


either chronicle seems work, e.g.:



foo f1;
foo f2("name", 30);


which impression move advise why?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?