Search code examples
c++classincludec++buildervcl

VCL Forms Application


I have written some C++ Classes for a console application.

How do I use these classes in a VCL Forms Application. I am using C++ Builder XE2.

I have added the .h and .cpp files via the Project->Add to project. Do I need to write an include statement? If so, where do I do this?

I tried placing the include statements at the top of the .cpp file, yet I get the following error: Unable to open include file.

I have the .h and .cpp files in the same directory as the Forms project.

Thanks


Solution

  • This is a quick hack. It worked for me.

    Move the entire class you wrote from the .CPP file in to the .H file. Move everything.

    In the .CPP file of the vcl form, form1.cpp, include the .H file that contains the C++ Classes.

    or you could just paste parts of the class methods into form1.h so they become part of the public ref class form1{}; class all together instead of having two different classes clash, the form1 class and your class.