What is the best way to distribute a C ++ class

I created a big C ++ class. I need to transfer it to another person. I do not want him to see the implementation of functions, but he should have used it as a class. (for example: it can inherit this class, use its full functionality in its code, but cannot see or change the implementation of functions, etc.)

How can i do this. thank you..

+3
source share
5 answers

Your code is hardly worth keeping a secret. Some C ++ code, such as templates and functions that you want to embed in user code, should be placed in the header file. If you really need a measure of secrecy, you can put the implementation of functions without templates in a .cpp file, compile them into a library, and then distribute the header and library. Of course, the user can still check the machine code for the library.

+8
source

In C ++ a, classit's simple: a syntax construct. You can organize your classes by file as you wish. You can put each class in its own pair of header files /.cpp, create classes just for the header, distribute them over many files - as you like.

++ , . , - , ( ) , . ( ).

, ++ .h .hpp. ( , , .)
(.cpp), . , ( Unix- , .a, Windows .lib).

, :

  • . .
  • , , , libary.

    , , . ++ API , , , .
    , ( , , , , ), ( ),

    , , inline . ++, , ?

, . , , : , .

+7

.cpp , , .lib.

0

Create a shared or static library from your sources and distribute header files for others to use your class. Anyone using your class should reference your library.

0
source

The closest thing to what you want will be to create a .dll for Windows or a .so for linux and a lib file to go with this and provide it to the appropriate person.

0
source

Source: https://habr.com/ru/post/1748328/


All Articles