C ++ Question about default constructor

What does it mean to call a class as follows:

class Example
{
 public: 
  Example(void);
  ~Example(void);
}

int main(void)
{
 Example ex(); // <<<<<< what is it called to call it like this?

 return(0);
}

As if it does not call the default constructor in this case. Can someone give a reason why this would be bad?

Thanks for all the answers.

+5
source share
4 answers

You are currently trying to call the default constructor.

Example ex();

This is actually not a call to the default constructor. Instead, you define a function prototype with a return type and no parameters. To call the default constructor, omit the () character

Example ex;
+16
source

ex, Example! .

+8

? , . .

+4

, Example ex(); . , . ++ ​​ ++ 0x. Example ex{};. , .

+2

All Articles