Friend class from separate headers

Hello world!

I was wondering if when one class from one header declares another class from a different header as a friend does the class prototype go befor or after the macro guard? Also do i need to include the friended class header?

Thank you and sorry if this question has already been answered; but i couldn't find a clear answer.
You don't need a full declaration, a forward declaration will suffice.
Thanks kbw. But can you say if the forward declaration should come befor or after the macro guard inside the friending class header?
closed account (Dy7SLyTq)
it should come after right? the whole point of the macro guards is to only allow everything if its been declared once
But can you say if the forward declaration should come befor or after the macro guard inside the friending class header?

It's tidier to declare the forward definition within the header guard, and there's no point getting the compiler code to parse code unnecessarily, but at the end of the day it doesn't really matter. You can have as many declarations as you want, as long as you only have a single definition.
http://en.wikipedia.org/wiki/One_Definition_Rule

Andy
Topic archived. No new replies allowed.