Reputation: 91
I am working on a project and I need to make a class which I will share using a static library. So far I wrote the implementation inside a .cpp file and shared only de .h and .lib files. If I use those inside another project and I try to debug something that uses my class I am able to see the full implementation written in the .cpp file. Is there any way I could hide the implementation?
Upvotes: 1
Views: 247
Reputation: 406
You can use the pimpl idiom to hide the implementation.By switching to pimpl idiom, you can change your implementation anytime without affecting the way your client uses library.
But to your question, if you are distributing your header and library file only, then others won't be able to see your implementation. The library has embedded info about your source files in your machine. That's why you are able to debug like that.
Upvotes: 0
Reputation: 136266
If I use those inside another project and I try to debug something that uses my class I am able to see the full implementation written in the .cpp file. Is there any way I could hide the implementation?
You can only see the implementation in .cpp
because:
.lib
has debug information not stripped..cpp
file happens to be in a location mentioned in the debug information (i.e. there is no copy of .cpp
inside .lib
).If you remove any of the above conditions you won't be able to see the source in the debugger.
Upvotes: 1