Похожие чаты

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 ответов

8 просмотров

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

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

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

Какой-то там пердун в 90-х решил, что есть какая-то разная типизация. Кого вообще это волнует?
КТ315
49
Hi. Do we have a raid bot? Why nobody doing raids on X? Even RH mentioned this and nobody paying attention...whats the channel for hex memes? If mods cant run raids just insta...
H
31
Подскажите, а есть vault lite или ченить такое?) А то нужен вольт для похода в вольт, но весит он ~500 мб) как-то многовато для парочки запросов ))
Alexandr Orloff
17
блеать, почему так?? где в роутере это исправляется?
Арсен Маньяков 🇦🇲
16
void terminal_scroll() { memmove(terminal_buffer, terminal_buffer + VGA_WIDTH, buffer_size - VGA_WIDTH); memset(terminal_buffer + buffer_size - VGA_WIDTH, 0, VGA_WIDTH); ...
Егор
47
🌊 Ocean Nodes Dashboard Update 🚀 Hey, Oceaners! First off, a massive round of applause 👏to all of you for the amazing engagement since we launched Ocean Nodes. In just a few ...
KreigDK | Never DM first🌊
3
Всем привет! Подскажите, пожалуйста, в чем ошибка? Настраиваю подключение к MySQL. Либы лежат рядом с exe. Все как по "учебнику"
Евгений
16
А можете как-то проверить меня по знаниям по ассемблеру?
A A
132
Здравствуйте! У меня появилась возможность купить книгу "Изучай Haskell во имя добра!". Но я где-то слышал, что эта книга устарела. Насколько это правда??
E
22
люди, которые используют flameshot, к вам вопрос. Можно-ли поставить хоткей на создание скриншота? В программе есть отдел "горячие клавиши", но там все для редактирования, скр...
ThunDer104
11
Карта сайта