//header file
namespace testns{
//I was thinking that if you could friend a namespace
//you could allow instant higher privilege access
//for people who want to make functions that access
//private members without subclassing it
};
struct imastruct{
private:
friend testns;};
//file that includes above header
namespace testns{
//here they would be able to define functions that can
//access private members of imastruct
};
I'm not really sure what the problem with that is... If they screwed with the class to that point that it was nonfunctional, they would only be hurting themselves because they are including and using it.
It would kind of violate the whole point of encapsulation if you allowed anyone to create functions themselves that modified private variables in your class.