Reputation: 1771
Suppose I have a function in C++ which is taking multiple parameters so what should be the order of parameters.
e.g.
class Date
{
//heavy class
};
func(int, std::string, Date, ...)
Just curious is there any convention to pass parameters depending upon datatype
.
I got this link in stackoverflow, but still want to check if there any more info on this - Conventions for order of parameters in a function
Upvotes: 1
Views: 476
Reputation: 234875
No there isn't.
Note that C++ doesn't even specify the order in which function parameters are evaluated and passed to the function, although the evaluation of arguments is sequenced. So writing something like func(cheap_function_that_might_throw_an_exception(), expensive_function())
may not necessarily be an optimisation.
Your best bet is to be consistent in your application.
Upvotes: 3