Ok now it looks like this:
----------------------------------------------------
1 2 3 4 5 6 7
|
//(mod.h)
#ifndef MOD_H
#define MOD_H
namespace M {
int fun (int);
}
#endif
| |
----------------------------------------------------
1 2 3 4 5 6 7 8 9
|
//(mod.cpp)
#include "mod.h"
namespace M {
int fun (int x){
x=x*x;
return x;
}
}
#endif
| |
----------------------------------------------------
1 2 3 4 5 6 7 8 9 10
|
//(mainmod.cpp)
#include<iostream>
#include<mod.h>
using namespace std;
using namespace M;
int main(){
int a=10;
cout<<fun(a)<<endl;
return 0;
}
| |
----------------------------------------------------
So i put these 3 files in one directory, than change directory
to that and compile it writing: g++ mainmod.cpp mod.cpp -o prgmod
and there are these errors:
mainmod.cpp:2:16: error: mod.h: No such file or directory
mainmod.cpp:3: error: ‘M’ is not a namespace-name
mainmod.cpp:3: error: expected namespace-name before ‘;’ token
mainmod.cpp: In function ‘int main()’:
mainmod.cpp:8: error: ‘fun’ was not declared in this scope
mod.cpp:11:2: error: #endif without #if
Can anyone help me?