I
Immortal Nephi
How can you hide your implementation source code? You do not want
other programmers to know your source code, but they can only include
interface header. They do not require to know private_foo function.
They only need to use public_foo function when they are ready to link
it to private_foo function’s object code.
Is my example below correct? Please comment your suggestion. The
class keyword can be used in the implementation source code. How do
you say protected or private keyword are not necessary?
// Implemenation.h
int private_foo( int x, int y );
// Implemenation.cpp
#include "impemenation.h"
int private_foo( int x, int y )
{
int z;
for( int a = 0; a < 10; a++ )
z += ( x * y );
return z;
}
// Interface.h
#include "impemenation.h"
int public_foo( int x , y )
{
return private_foo( x , y );
}
// main.cpp
#include "interface.h"
int main()
{
int x = 5;
int y = 10;
int z;
z = public_foo( x , y );
return 0;
}
other programmers to know your source code, but they can only include
interface header. They do not require to know private_foo function.
They only need to use public_foo function when they are ready to link
it to private_foo function’s object code.
Is my example below correct? Please comment your suggestion. The
class keyword can be used in the implementation source code. How do
you say protected or private keyword are not necessary?
// Implemenation.h
int private_foo( int x, int y );
// Implemenation.cpp
#include "impemenation.h"
int private_foo( int x, int y )
{
int z;
for( int a = 0; a < 10; a++ )
z += ( x * y );
return z;
}
// Interface.h
#include "impemenation.h"
int public_foo( int x , y )
{
return private_foo( x , y );
}
// main.cpp
#include "interface.h"
int main()
{
int x = 5;
int y = 10;
int z;
z = public_foo( x , y );
return 0;
}