Похожие чаты

Can anyone explain to me , why there is no

error?
And why I delete the operator has an error

2 ответов

10 просмотров

First: when you have a constructor thst takes one argument, and this constructor is not marked as explicit, that means your type can be converted implicitly from that type. Example is line A a2 = i Second: operator Type() is conversion operator, if it's not marked explicit it means object of your class can be converted to Type implicitly. Example is line i = a1 More details here: https://en.cppreference.com/w/cpp/language/implicit_conversion and here https://en.cppreference.com/w/cpp/language/cast_operator The last two lines are explicit conversions, Note also that this code have some issues (apart from absence of explicit). The last two lines are using c-style casts that are not usually used in C++ (bad code style) and the constructor should set x in constructor intialization list instead of assigning it in the constructor body. Details: https://softwareengineering.stackexchange.com/questions/50442/c-style-casts-or-c-style-casts and https://en.cppreference.com/w/cpp/language/constructor

In the second line of main, I think you declare a variable called a2♒i

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

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

коллеги, добрый вечер! А никто не знает как модальная форма может себя закрыть? Ну допустим модальная форма определила, что смысла ей работать нет и хочет вернуть modalResult...
Михаил
46
Hi there everyone Is there anyone who have not started hamster bot yet? I need only one, I'll be glad if you do this for me DM if you haven't yet
Mehrshad
53
Да и не жалко вроде как, подумаешь, обсудить другой дистр... Только есть три момента: 1) такие разговоры постоянно норовят свалиться в обоюдные оскорбления и страшные холивары...
Dan (つ•̀ᴥ•́)つ
24
I guess nothing new happening this week?
KDA MAXI
14
We will see what we can do and what we can share . Like you need report from each iExec dev what he did today and will do tomorrow?
Yderf 88
13
hi, anyone use barrel files? im using this pattern lots of time and in lots of projects today i read some blogs about barrel files that they say barrel files damage performan...
Ali
12
А как старый хаскел с новым стыковать ? потому как тут работает https://play.haskell.org/saved/C3xpMzcd, а вот тут https://stepik.org/lesson/7602/step/9?unit=1473 нет ошибка C...
Fedor
131
hi my MyAsus app has informed me of a new version of bios (version 300), i tried installing it but after this attempt it said: Update failed. Does anyone have any solution? My...
Sahand 🏔️
13
всем привет! у кого есть опыт подписания и нотаризации electron приложений для macos? такая проблема: использовал @electron/osx-sign и notaritool. процесс подписания и нотараз...
Артем Клементьев
11
Btw, re Privact Pass I asked this a couple of days ago. Got no reply at all. Perhaps I can get an answer now? Btw, shouldn’t we be seeing much more on privacy pass? When regi...
Jdr
5
Карта сайта