'How to includue multiple .cpp files into one main file [duplicate]
now in real world when building projects we use hunderends of .cpp files and we link them into one main.cpp file.
Main.cpp
#include <iostream>
#include <function>
int main()
{
print("hello");
}
function.cpp
#include <iostream>
using namespace std;
#include <string>
void print(string s)
{
cout << s;
}
I'm using c++(microsoft) on visual studio code
terminal
C:\Users\Sainath\Desktop\Project>cl main.cpp
C:\Users\Sainath\Desktop\Project>main
then we get an output
output
hello
Is there any way to do something like this? I could use Visual studio to build and run it as one whole .cpp, but I want to understand on how this thing works
edit: I mean we dont explicitly compile iostream but it stil gets compiled during preprocessor time, Is there any way to do automate function.cpp compilation without explicitly doing it?
` Blockquote
`
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
