Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?


Product Version: Not Selected
more ▼

asked Apr 06 '15 at 09:06 AM in C++ Programming

avatar image

15 3 5 6

avatar image mrooney May 05 '15 at 02:45 PM

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.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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"


 #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!

more ▼

answered May 05 '15 at 02:38 PM

avatar image

Andrii Melnyk
1.8k 59 17 111

avatar image HamkenDevelop May 06 '15 at 04:28 AM

Hi, Andrew Melnick

Thanks for your assistance!

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

avatar image acajic Aug 14 '18 at 08:11 AM

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...

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question