Похожие чаты

Hello, i have the following problem: I have two classes:

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?

13 ответов

9 просмотров

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 😄

Pavel
You can do some really wierd thing like: Make a fu...

mfw the dirty hack I propose is actually clean compared to that xD

I think the better question is, why do you want this?

olli
I think the better question is, why do you want th...

Agreed, I am quite confused on how the friend is not acceptable given that is is the very usecase for it

kn07-_ Автор вопроса
olli
I think the better question is, why do you want th...

Because one function call for each mesh is expensive.

kn07-_ Автор вопроса
Pavel
You can do some really wierd thing like: Make a fu...

Well, it's a good ideea, but the whole point is to avoid function call.

kn07 _
Because one function call for each mesh is expensi...

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.

kn07-_ Автор вопроса
kn07 _
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

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта