3

What is the difference between CRect c; and CRect c(), when CRect is a class?

Yakov Galka
  • 66,221
  • 15
  • 132
  • 206
Aditya
  • 245
  • 1
  • 3
  • 14

2 Answers2

6
CRect c; 

defines an object

CRect c(); 

declares a function returns CRect object.

Sometimes people are not aware of second form and get caught by most vexing parse.

daramarak
  • 5,964
  • 1
  • 31
  • 50
billz
  • 43,318
  • 8
  • 77
  • 98
6

This one

CRect c;

creates a CRect object called c.

This one

CRect c();

declares a function called c() that returns a CRect object. It is a parse that is vexing, however, it isn't the most vexing one.

juanchopanza
  • 216,937
  • 30
  • 383
  • 461