c++day5

class Sofa
{
protected:
    string sit;
public:
    Sofa()
    {
        cout << "沙发无参构造" << endl;
    }
    Sofa(string s):sit(s)
    {
        cout << "沙发有参构造" << endl;
    }
    Sofa(const Sofa &other):sit(other.sit)
    {
        cout << "沙发拷贝构造" << endl;
    }
    Sofa &operator=(const Sofa &other)
    {
        cout << "沙发拷贝赋值" << endl;
        if(this!= &other)
        {
            sit = other.sit;
        }
        return *this;
    }
    void show()
    {
        cout << "sit=" << sit <c++day5_第1张图片

你可能感兴趣的:(c++,开发语言,算法)