struct

points to remember about structs

  • Within a struct declaration, fields cannot be initialized unless they are declared as const or static
  • struct does not have a default constructor
  • struct is a value type
  • struct constructor is automatically created by the compiler initializing the fields with the default values
  • structs inherit from another struct or class, and it cannot be the base of a class
  • When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.
  • struct cannot be a base class for  another class
  • struct can implement an interface
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: