How can I export class file to another project?

I have a my c++ class in a project.

I would like to import that class to any other project.

How can I do this?

Thanks

Hello, HamkenDevelop

For this, please do the following:

  1. Copy the ClassForExport.h and ClassForExport.cpp from SourceProject\Source\SourceProject to DestinationProject\Source\DestinationProject.

  2. In ClassForExport.cpp replace

    #include “SourceProjectName.h”
    with

    #include “DestinationProjectName.h”

  3. In ClassForExport.h replace the SOURCEPROJECT_API macro with DESTINATIONPROJECT_API (it is located in the line

    class SOURCEPROJECT_API AMyActorForExport : public AActor

  4. In Visual Studio, right-click on your destination project in solution explorer and select Add - Existing Item. Choose the appropriate .h and .cpp files of your class.

  5. Rebuild the project.

This should do it. Please, however, note, that in case your class has some additional includes for files in its original project, you should also take care of them.

Hope this helped! Cheers!

Which IDE are you using for your code? VS? You should be able to just copy the classes if you want to go quick and easy, or you can package it as a plugin to be able to reuse it elsewhere also.

Hi, Andrew Melnick

Thanks for your assistance!

I was able to export a my c++ class to the other project.

So, basically, I should behave as if I am writing these classes from scratch. Just instead of actually writing them, I copy them from another project?

I was hoping to find some option to export a project into some kind of package/plugin which I can easily import into another project…