Pointer initialization

Currently, I am confused with the following statement: although this statement would give an error at compile time, but it is not.

// statement 1:
someclass* q(someclass());

I understand if this statement was that way

// statement 2:
someclass* q(&someclass());

I would like to know why statment 1 does not generate an error, or even if it is valid (is there anything that I am missing behind the curtains?)

+5
source share
2 answers

I would like to know why statment 1 does not generate an error or even if it really is

, , , , : q, someclass , , , someclass. Vexing Parse.

: q someclass , someclass(). , , someclass() , .

+12

1 . q , someclass, someclass.

. Vexing Parse.

+3

All Articles