Compilation unit
How can I restrict a class and its methods not to be exported out of the compilation unit?
The same way I use 'static' in front of a function declaration.
Thanks!
Now compile with:
I think it should print "3 3", but it prints in my computer "3 nan".
The same way I use 'static' in front of a function declaration.
Thanks!
/* file test.cpp */
#include <iostream>
using namespace std;
class A
{
public:
int val;
int f()
{
return val;
};
};
float f2();
int main()
{
A i;
i.val = 3;
cout << i.f() << ' ' << f2() << '\n';
return 0;
}
/* End of test.cpp */
/* File test2.cpp */
class A
{
public:
float val;
float f()
{
return val;
};
};
float f2()
{
A v;
v.val = 3.;
return v.f();
}
/* End of test2.cpp */
Now compile with:
g++ -o test test.cpp test2.cpp
I think it should print "3 3", but it prints in my computer "3 nan".
