Hi, I was wondering for default parameter values, if we could set a default value to be the return value of a function. Specifically, I'm asking if I can do this:
DerivedClass(const char* str, int l = (strlen(str)))
The above is a constructor for a class. I'm currently getting a "'str' is an undeclared identifier" error in Visual Studio when I try to do this. What is the correct syntax?
Also, if something like the above is possible, should I be doing this in the header file or implementation file?
As for whether it goes in the .h or the .cpp file, that depends on whether you want it inlined or not. My general rule is that if the function is small I inline it (put it in the header).