首页 > 解决方案 > 为什么调用 A a(A()) 什么都不输出?

问题描述

我想知道这段代码发生了什么?而且,调用 A a(other) 有什么不同。

#include <iostream>
#include <string>
#define LOG() (cout << __PRETTY_FUNCTION__ << endl)

using namespace std;

struct A
{
    A() { LOG(); }
    A(const A&) { LOG(); }
    const A& operator=(const A&) { LOG(); }
};

int main(void)
{
    A a(A());
    return 0;
}

什么都不输出。

标签: c++

解决方案


推荐阅读