simple question

D

Daniel T.

Neo said:
What would be the use of having a protected member class as a friend?

That question can be interpreted a number of ways.

class Foo {
protected:
Bar bar;
friend class Bar;
};

Is the above what you mean? If so, it means that objects of type Foo,
objects of type Bar and objects of any type derived from Foo can access
the 'bar' member-variable.

or...

class Foo {
protected:
friend class Bar;
};

as opposed to:

class Foo {
public:
friend class Bar;
};

or

class Foo {
private:
friend class Bar;
};

The 3 above are all the same.
 
S

Salt_Peter

What would be the use of having a protected member class as a friend?

-Neo

did you mean an embedded class?

If so...
A good use for it is to remind you that the design is probably flawed.
Next time, any chance you might present the problem by code?
A simple toy class that shows the structure/ construct would do.
 
N

Neo

That question can be interpreted a number of ways.

class Foo {
protected:
Bar bar;
friend class Bar;

};

Is the above what you mean?

Sorry for the confusion. Yes, this is what I had in mind. Thanks for
the replies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,976
Members
47,533
Latest member
medikillz39

Latest Threads

Top