Update: I ended up getting this work by using DLLs and loading and unloading them. https://www.youtube.com/watch?v=mFSv0tf6Vwc
I know its possible because I've seen posts about this but i don't really understand them.
So i have class(DetailsLayout) that calls a method in another class(Components). At runtime i change the contents of Components to add another component that the user created to that method. I want to recompile the DetailsLayout.cpp and the Components.h but i'm confused as to how to go about this.
right now i'm trying this because of this post : Using G++ to compile multiple .cpp and .h files
system(("g++ -c ProjectComponents.hpp").c_str());
system(("g++ -c DetailsLayout.cpp").c_str());
DetailsLayout::CreateMenu();
I get an error that says g++ is not recognized as an internal or external command.
as per Jesper's suggestion ill mention what id like my end goal to be. So right now in my Game Engine i allow users to add components (that i made) to objects in the scene dynamically. When i tried to make it so that the "user" can make a component and add it dynamically i couldn't do it unless i compiled the .h and .cpp file i made for them. If i manually include the file into my project and run the method for adding the class it works but i want that to happen when i click a button for compiling.
My Components all inherit from this class.
class Component
{
public:
Component();
~Component();
virtual bool Initialize() { return true; }
virtual bool Update(float dt) { dt; return true; }
virtual bool Draw() { return true; }
template <class T> T* GetSiblingComponent()
{
return m_owner->GetComponentByType<T>();
}
protected:
Entity* m_owner;
char m_name[Imgn::MAX_NAME_LEN];
bool m_enabled;
};