is it valid if I define member functions with same name¶meters but different return types inside a class like this:
class Test {
public:
int a;
Const and non-const methods with the same formal parameter list can appear side-by-side because the this pointer is treated as a hidden argument and would have a different type. This may be used to provide mutating and non-mutating accessors as in the code in your question.
If the signatures are exactly the same, then no.