CLR (function, .cpp) Visual studio

Can someone explain what a .cpp file doing for form? And how do I run a custom function from any button? Thanks in advance.
Last edited on
A .cpp file is just a C++ source file that contains, well, the source code. Header files may also contain source code, but that really depends on how you write your programs.

Hex231 wrote:
And how do I run a custom function from any button?

Assuming we're thinking about the right term for "functions", you can declare your functions in the source file and implement them there or you can declare them in the header (as a prototype) and implement them in the source. Or you can declare and implement the function in the header file, but that wouldn't be very good practice now would it?
the .cpp files for forms are generated classes that define the form (assuming form == window and the API you are using is like the ones I use?). The IDE build the code for you, but its still just code. When you double click the button on the form (assuming your IDE and tools work this way) it should create the (empty) method for the button (a handler, as they are called) that executes the code when the button is clicked, you just fill in the code between the {} which is usually just a function call to something you wrote (its best if that is all you do here so if you change GUI libraries/platforms you don't have to extract real code from the GUI code).

The questions you are asking are about some specific tools, not the C++ language. That is OK, but we need to know what you are actually using here.
Last edited on
Topic archived. No new replies allowed.