My class interferes with library class
I am currently programming on a 3d visualization program so I wrote my own Vector3 class to have some convenient vector operations. That worked fine until I needed to load some Meshes which I used an external library for that has its own Vector3 class. Now the compiler can't tell them apart and I can not change both because they are too heavily included in the code. Has anyone an idea how I can separate them for the compiler?
I thought about creating a namespace around the inclusion of the loader but got errors in the libraries implementation.
Any Ideas would be a开发者_StackOverflow社区ppreciated.
EDIT Unfortunately my own project as well as the library have no own namespace.
(Solved) Ok I solved this by removing the library and refactoring my code automatically with eclipse. But if it would not be able to do this how could I solve this problem in C++ independent from the IDE? -> Not marked as answered
EDIT Unfortunately my own project as well as the library have no own namespace.
The solution is obvious. Put your project in a namespace. And refer to the Vector3 in the library with ::Vector3, if it truly does not have any namespace.
Use your project namespace before the classname you have created, and its builtin class. like:
MyProject::Vector3D
xxx::Vector3D
where 'xxx' is the namespace in which builtin Vector3D class is in.
精彩评论