I need a template function which assigns a default value to the argument passed
template <class T> inline T GetDefault()
{
return ???? # default value
}
T cand be bool, int, double and string.
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Default value (even with basic types) should be default “constructor” :
For example, int-based types will be 0 by default (because explicitely initialized).
This will obviously not work with types with no default value, like objects of class that don’t have a default constructor.