I have been looking for a reply for this a lot, but I cannot find nothing. My compiler doesn't give me any error or warning, but maybe there could be any danger into doing this:
class Dog
{
Dog(): x(0) {}
int x;
};
If I have a simple class, creating a function in another class like this:
class PetHouse
{
void addDog(Dog& animal = Dog())
{
// Anything...
}
};
Is the addDog() declaration right? I have an argument which is a reference and it's default value is a Dog() object, instead an existing object.
Is there any danger?
Thanks for reading!