A, B. A has a private field x. I want to give B access to field x, but without a getter or making class B as friend of class A. Any sugestions?
Why no getter ? It seems odd for descendant to be friend.
you could hack a way around by using offsetof but appart from that idk
You can do some really wierd thing like: Make a function in A that accepts a reference to B as an argument and calls B's function with the value of x. Then split your logic to continue in that function. But that is super wierd and I would not suggest to do that unless you hate the people who will support that code 😄
mfw the dirty hack I propose is actually clean compared to that xD
I think the better question is, why do you want this?
Agreed, I am quite confused on how the friend is not acceptable given that is is the very usecase for it
Because one function call for each mesh is expensive.
Well, it's a good ideea, but the whole point is to avoid function call.
Have you measured the impact? I'd suggest rethinking your architecture if A needs to access a private member of B and you can't do function call. But yeah,... Lack of context
and i did not talk about your question sir.
It would be better to make my repo public?
one philosophy of making the source code open is that anybody that are interested and have enough time and resources could help. if you want that so do what mr linus torvalds did that made linux a good product among human created disasters
Обсуждают сегодня