Похожие чаты

Hi there, Do you have any problem copying class ? ISomething& alias

= getSomething()

CSomething *m_pSomthingImpl;
ISomething& getSomething()
{
return *m_pSomethingImpl;
}

if CSomethingImpl has some member variable,
the copy is not successfull leave _vptr with 0.
I though reference & is just an alias.
There is no need to copy data.
CMIIW.

getSomething().dismiss() <- it works.
but alias.dismiss() <- it doesnt.

9 ответов

23 просмотра

Works for me without issues, can you provide the code that works unexpectedly? https://wandbox.org/permlink/dxz05G7Q3hgGmwgm

John- Автор вопроса
Pavel
Works for me without issues, can you provide the c...

Because address of new object, luckyly the same. Therefore, Reference should not be used. *Alias is not set to another object yet. Sorry, just replied.

John
Because address of new object, luckyly the same. T...

Do you have a code example where it breaks? To understand what you mean

John- Автор вопроса
Pavel
Do you have a code example where it breaks? To und...

ISomething& temporary = getSomething(case1); temporary = getSomething(case2); temporary.dismiss() There should be error on case2 temporary.dismiss(). But it is ok if just : getSomething(case1).dismiss(); getSomething(case2).dismiss();

John
ISomething& temporary = getSomething(case1); tempo...

We couldn't compile this, give us a complete program including the problem.

John- Автор вопроса
John
Thanks Sir. Been solved.

Could you say the solution? i really don't understand what is your problem with the references: https://t.me/c/1071392087/169968

John- Автор вопроса
Ghasem Ramezani
Could you say the solution? i really don't underst...

Once initialized,reference cannot be changed to another object. https://en.cppreference.com/w/cpp/language/reference_initialization

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
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
Карта сайта