You are here:

C++/header file

Advertisement


Question
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

Answer
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

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

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 ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

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.

©2016 About.com. All rights reserved.