user1561358 user1561358 - 1 year ago 71
C++ Question

Defining functions of a class in .cpp of a Dynamic-link Library

Recently I started working with c++ and I was wondering.
If I'm working on DLL, I first define all the classes and and their functions in the header and then write their functionality in

file in the same project.
But what if I instead defined only the classes themselves and then defined their functions in

It would somewhat reduce the amount of code required and the code would be more readable with much less

Is something like that possible?

Answer Source

You have to define your classes(structs, etc) and declare your namespace(s) and functions in your header. That being said, you can use

using namespace <your_library_namespace>;

And then everything in your source file in <your_library_namespace> won't need to use <your_library_namespace>:: before everything.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download