On line 6 in the main-file you are trying to print an undefined variable. The plus() function should return a value and you should assign that value to a variable and then print the variable.
main.cpp
1 2 3 4 5 6 7 8
#include <iostream>
#include "subfile.h"
usingnamespace std;
int main() {
int result = plus(5, 11);
cout << result <<endl;
}
subfile.h
1 2 3 4
int plus(int x, int y) {
result = x + y;
return result
}
sub.h: In function ‘void plus(int, int)’:
sub.h:3:8: error: return-statement with a value, in function returning 'void' [-fpermissive]
return result;
^
plFTP.cpp: In function ‘int main()’:
plFTP.cpp:6:3: error: reference to ‘plus’ is ambiguous
plus(5, 11);
^
In file included from plFTP.cpp:2:0:
sub.h:1:6: note: candidates are: void plus(int, int)
void plus(int x, int y) {
^
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from plFTP.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:140:12: note: template<class _Tp> struct std::plus
struct plus : public binary_function<_Tp, _Tp, _Tp>
^
plFTP.cpp:7:10: error: ‘result’ was not declared in this scope
cout<< result;