- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Using G++ to compile multiple .cpp and .h files
To compile multiple files like file_name.h, or file_name.cpp at once, we can use the files like a list one after another. The syntax will be like this −
g++ abc.h xyz.cpp
To run the program, we can use this −
./a.out
Example
float area(float r){ return (3.1415*r*r); //area of a circle } float area(float l, float w){ return (l * w); //area of a rectangle }
Example
#include <iostream> #include "area.h" using namespace std; main(){ cout << "Area of circle with radius 2.5 is: " << area(2.5) << endl; cout << "Area of rectangle with length and width are 5 and 7 is: " << area(5, 7) << endl; }
Output
$ g++ area.h find_area.cpp $ ./a.out Area of circle with radius 2.5 is: 19.6344 Area of rectangle with length and width are 5 and 7 is: 35 $
- Related Articles
- Compiling multiple .cpp files in c++ program
- Why does C++ have header files and .cpp files?
- Rename multiple files using Python
- Rename multiple files using Java
- How to rename multiple files recursively using Python?
- How to include multiple js files using jQuery $.getScript() method?
- How to copy multiple files in PowerShell using Copy-Item?
- Multiple .java files
- How to merge multiple files into a new file using Python?
- How to spilt a binary file into multiple files using Python?
- How to open multiple files using a File Chooser in JavaFX?
- How to compile code using Arduino IDE
- Python - Write multiple files data to master file
- How to share common data among multiple Python files?
- How to upload multiple files and store them in a folder with PHP?

Advertisements