3

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

Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
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
  • 6,115
  • 1
  • 31
  • 50
billz
  • 44,644
  • 9
  • 83
  • 100
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
  • 223,364
  • 34
  • 402
  • 480