How to declare copy constructor in derived class, without default construcor in base?
Call the copy-constructor (which is generated by the compiler) of the base:
Derived( const Derived &d ) : Base(d)
{ //^^^^^^^ change this to Derived. Your code is using Base
std::cout << "copy constructor\n";
}
And ideally, you should call the compiler generated copy-constructor of the base. Don't think of calling the other constructor. I think that would be a bad idea.
You can (and should) call the copy ctor of the base class, like:
Derived( const Derived &d ) :
Base(d)
{
std::cout << "copy constructor\n";
}
Note that I turned the Base parameter into a Derived parameter, since only that is called a copy ctor. But maybe you didn't really wanted a copy ctor...