I have such class in A.h :
class A { public: A(int *object) { std::cout << "convert"; } A(A &object) { std::cout << "copy"; } }; and in main.cpp
A a = new int; then, when I'm trying to compile it i get
invalid initialization of non-const reference of type ‘A&’ from an rvalue of type ‘A’
but when i add const to copy-constructor like that:
A(const A &object) { std::cout << "copy"; } code compiles and "convert" is called. It works when i remove copy constructor, too. Why such thing happen? I though this example has nothing to do with copying constructor as we do not use instance of class A to create another.