Does making a class a 'friend' make the class' member classes 'friends'?
Based on previous compiles of my particular code, I would assume yes, but I've been fighting an issue where I keep getting privacy errors in this case.
Code:
class Cat; error: `void Vase::smash()' is private If that doesn't work, what should be done? Thanks |
Hi.
Maybe you should put 'public:' just before 'void wag(...)'? Code:
#include <iostream> |
Before, I really wanted to reply with the following, without even fully looking at the code:
"Just make it public." Guess I was right :p |
Quote:
Quote:
Quote:
|
Just found this thread. As I understand, there are no single opinion about this problem in C++ standard currently in use, but newer standard C++0X seems to allow that access.
|
Quote:
|
Quote:
Code:
class Cat; Side topic, but is 'friend' perceived as being a huge hack in C++? EDIT Code:
#include <iostream> Quote:
|
My not-so-good anymore eyes (shaddup... it will happen to you, too!) are starting to glaze-over here.
If you're starting to write code that ventures into this kind of esoterica in the definition (past or present or future) of the C++ language ... ... then you need to be advised from the outset that "you are in the process of making what will one day be regarded as a package of unmaintainable sh*t." :eek: Please, hear me out. If there are but two things that are absolute constants in the world of software, they are these:
When you are writing software... "please, don't be clever." Every time you avail yourself of features such as "friends," you are (whether you realize the long-term implications of your actions or not ...) creating a wicked and utterly intractable functional dependency between the two that one day just might be regarded as the relationship between Harry Potter and Lord Voldemort. I'll step off my soapbox now. But please, mark my words. I've spent most of my thirty-plus year career untangling what was once "clever" software. And sometimes it feels just like disarming a most-delicate bomb. The most noble of intentions, practiced by obviously skilled and knowledgeable programmers, can nevertheless turn into ... scrap. And, if I may bluntly say so, "the more 'clever' it is, the more likely it is to be unsalvageable." :jawa: (And let no one call me a Luddite, because you would not know whereof you speak. Just sayin' ...) The guy who runs the junk-yard does have a valid opinion with regard to cars. |
All times are GMT -5. The time now is 06:15 AM. |