Home > Code Analysis > Code Issues – Constructor must declare a body

Code Issues – Constructor must declare a body

January 21st, 2011

Cause:

The Constructor must declare a body code issue shows an error if there is a constructor without a body. Constructors are similar to usual methods and whenever a class or struct is created, its constructor is called. Constructors should always declare its body to properly initialize a class or struct.

Sample:

CodeRush Code Issues - Constructor without body

How to fix:

  • Declare the body of the constructor:

CodeRush Constructor Must Declare A Body Fix

See the full list of code issues specific to constructors.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/19/2012
ID: C050

Similar Posts: