Quantcast
Channel: Make difference between copy and direct initialization - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Rocket Procd for Make difference between copy and direct...

As suggested by @HolyBlackCatThis will work as expected.#include <iostream>class UnusualClass{ public: UnusualClass(const int &n){ std::cout<<"Copy initialization"; } explicit...

View Article



Answer by HolyBlackCat for Make difference between copy and direct...

I believe it's impossible in general, but if you only want to support the two ways of initialization you listed, there are hacky solutions.You need two constructors, one explicit and the other...

View Article

Make difference between copy and direct initialization

Create an “UnusualClass” class in which direct and copy initialization produce different effects throughout. In particular, the attempt of direct or copy initialization should produce on the screen the...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images