Trying to compile multiple files

Consider those files:

main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
# include "file.h"

# include <iostream>
using namespace std;

int main()
{
    func();

    cin.get();

    return 0;
}


file.h
1
2
3
4
5
# pragma once

# include <iostream>

void func(void);


file.cpp
1
2
3
4
5
6
# include "file.h"

void func(void)
{
    std::cout << "A string" << std::endl;
}


I am trying to build an executable from them. This command(g++ main.cpp -o app.exe) I use gives me the following error:
undefined reference to 'func()'
Try
g++ main.cpp file.cpp -o app.exe
Thank you @salem
Topic archived. No new replies allowed.