Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Compiling multiple .cpp files in c++ program
Here we will see how to compile multiple cpp file in C++ program. The task is very simple. We can provide the names as a list to the g++ compiler to compile them into one executable file
To compile multiple files like abc.cpp, and xyz.cpp at once, the syntax will be like this −
g++ abc.cpp 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#include "area.cpp" using namespace std; main() { cout Output
$ g++ area.cpp 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 $
Advertisements
