I am writing a library. Is it a bad idea to have two classes with same name but each of the classes are in different namespace?
Using name spaces:
//forward declaration
namespace sparse {
class matrix;
}
namespace dense {
class matrix;
}
namespace dense {
typedef Index uint64_t;
class matrix {
public:
sparse::matrix tosparse();
};
}
namespace sparse {
typedef Index uint32_t;
class matrix {
dense::matrix todense();
};
}
Alternatively, I can use long names:
class sparse_matrix
...
In general, that's fine. That's exactly what namespaces are for. In this example it's not clear what the design goal is, so it's not clear whether this is an appropriate use of namespaces.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments