Gabriel Valedon Gabriel Valedon - 4 months ago 30
C++ Question

Header Files with Source Files C++

I am trying to implement Header Files with Source Files using C++, but in the terminal the give me some errors.

Here is the code:


#include <iostream>
#include "add.h"
using namespace std;

int main()
cout << "The Sum of 3 and 4 is: " << add(3,4) << endl;
return 0;


int add(int x, int y)
return (x + y);


#ifndef ADD_H
#define ADD_H

int add(int x, int y);


Terminal Messages:
Terminal Messages


You did use the C-compiler. The warning tells you that you provide C++-code to the C-compiler. In case you want to get rid of this warning, try clang++ -o add.o add.cpp followed by clang++ -o HeaderTest main.cpp add.o