Construct object with itself as reference?

后端 未结 6 1680
小鲜肉
小鲜肉 2021-02-02 03:26

I just realised that this program compiles and runs (gcc version 4.4.5 / Ubuntu):

#include 
using namespace std;

class Test
{
public:
  // copyc         


        
6条回答
  •  我在风中等你
    2021-02-02 03:57

    I don't know the spec reference, but I do know that accessing an uninitialized pointer always results in undefined behaviour.

    When I compile your code in Visual C++ I get:

    test.cpp(20): warning C4700: uninitialized local variable 'b' used

提交回复
热议问题