You are here:

C++/header file


i have created 3 functions in different files (i mean different main.c files) how can i create a header file and put all these functions in it as well as the main program that uses all these functions? i mean how can i create a header*.h file and put the functions and my program in it?Thanks a lot

Hello makis, thank you for the question.

Sorry, but one of the language constraints of the C/C++ languages are that you can only have one main function per application. If you have more than one, then you are going to get weird errors, not to mention a function redefinition error. What you can do is inline your other functions in a header file, then include the header file in another file with your single main function in it, then call your inlined header functions, if that helps at all.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 All rights reserved.