I have created a class inside a namespace now the problem occurs when i would have to use or call the namespace, What could be the possible reason for compiler error ??
namespace name1
{
class show
{
int a,b;
void accept_data(void);
void display_data(void);
friend void use_class(void);
};
}
Compiler Errors -
test1.cpp: In function ‘void use_class()’:
test1.cpp:17:6: error: ‘void name1::show::accept_data()’ is private
test1.cpp:31:16: error: within this context
test1.cpp:24:6: error: ‘void name1::show::display_data()’ is private
test1.cpp:32:17: error: within this context
You can have this:
and in main:
I am not sure why your functions have void parameters and return values though.
UPDATE:
this compiles and works:
But, if I write it like this:
I get your error. Make sure your
use_class
is part of same namespace.