How to call a function from another .cpp to the main one?

Hello everyone, I am new to C++ (I developed in python and have some java) but I liked the language so I thought on learning it using a book called "programming principles and exercises using C++". I have a hard time to understand how can I call methods from other files to main. For instance, I have made a header file called "square.h", a definition file called "sq.cpp" and the execution file called "the_main_function" bellow there is my code.

square.h file:

#ifdef _SQUARE_H_
#define _SQUARE_H
int s(int x);
#endif

sq.cpp file:

# include "square.h"
int s(int x){
return x*x;
}

the_main_function.cpp:

#include "square.h"
int main(){
s(10);
}

In the main I am getting an error stating that "s was not declare in the scope" why is that?
The first line in square.h should be #ifndef _SQUARE_H_ (note the "n" in #ifndef)
Should be
#ifndef _SQUARE_H

Note the negating n as 4th letter ... you are going to define this if it doesn't yet exist.
Note also there is no trailing underscore: the macro name must match precisely that on the next line.
Registered users can post here. Sign in or register to post.