1

The code

class C1
{

public:

    C1(const C1 &c) = delete;
    //{
    //  cout << "3\n";
    //}

    C1()
    {
        cout << "1\n";
    }

    ~C1()
    {
        cout << "2\n";
    }
};


C1 f()
{
    return C1();
}

Doesn't compile: error C2280: 'C1::C1(const C1 &)': attempting to reference a deleted function.

But, with copy consructor

C1(const C1 &c) 
{
    cout << "3\n";
}

It compiles and works, but the constructor doesn't execute.

Why ?

0 Answers0