I have a class with a member function with a lengthy return type:
/* MyClass.hpp */
namespace foo
{
class MyClass
{
public:
SomeNameSpace::Lengthy_return_type_name someFunction(params...);
};
}
I want to make this more readable without making things confusing for the reader, and I don't necessarily want to expose the typedef to the outside world. So in MyClass.hpp I added the following typedef within MyClass:
/* MyClass.hpp */
namespace foo
{
class MyClass
{
private:
typedef SomeNameSpace::Lengthy_return_type_name myType;
public:
myType someFunction(params...);
};
}
Now, in MyClass.cpp I have a dilemma because myType is not visible to be able to use as a return type. I could use MyClass::myType if I made the typedef public, but I don't like that since I think it is confusing and also exposes myType. I could also add the typedef to the top of MyClass.cpp, but this might take away from the meaning since readers would have to do a little digging to find out what the type is referring to.
Am I overthinking this? What is best practice in this case?