Declaring function from one cpp file to another

hello, simple stupid question, for pros, i have 2 cpp files, 1 has a function, the other is the main function, the 1 cpp file that has the main of course needs to have a declare of the function from the other cpp file so the function exists, yes i would use header, but i know if its (see below), what if it is an int and has 2 parameters, how do i declare that? can i get an example? or string?
 
void message(const char* message){ cout << "Test Test";}
closed account (1vf9z8AR)
void message(char message,int hello,string hi)
cool thanks Suyashsing, so even if the function is like:

1
2
3
4
int Adding(int a, int b)
{
return a+b
}


would i just put the following then?

 
int Adding(int a,int b);

would i just put this above into the other cpp file just like above?
If it's two ints:
 
int Adding(int, int);


If it's a string:
 
void Message(std::string const &);


Basically you put exactly what you would put if you were about to define a function (i.e. add the body)
Except it isn't necessary to specify parameter names if all you're doing is declaring it.

would i just put this above into the other cpp file just like above?

No, it should go in .h file.
Last edited on
Topic archived. No new replies allowed.