8

gcc 4.7.2 および MSVC-11.0 でコンパイルすると、次のコードの出力が異なるのはなぜですか?

#include <iostream>

class Base
{
public:
    Base()
    {
        std::cout << "Base::Base() \n";
    }

    ~Base()
    {
        std::cout << "Base::~Base() \n";
    }
};

class Derived : public Base
{
public:
    Derived()
    {
        std::cout << "Derived::Derived() \n";
    }

    ~Derived()
    {
        std::cout << "Derived::~Derived() \n";
    }
};

void foo(Base) {}

int main()
{
    Derived instance;
    foo(instance);
}

gcc 4.7.2

ベース::ベース()

派生::派生()

ベース::~ベース()

派生::~派生()

ベース::~ベース()

MSVC-11.0

ベース::ベース()

派生::派生()

ベース::~ベース()

ベース::~ベース()

MSVC-11.0 が秒を出力しないのはなぜDerived::~Derived()ですか?

https://ideone.com/NF9FQf

4

1 に答える 1