How class and a structure are different

How class and a structure are different?

E

Expert

Verified

a.) Class:

  • The class is a reference type.
  • During instantiating the class, CLR assigns memory for its instance in heap.
  • Class supports inheritance.
  • Variables of the class could be allotted as null.
  • It can contain constructor or destructor.


b.) Structure:

  • The structure is a value type.
  • Memory is assigned on stack.
  • It does not support inheritance.
  • Members of Structure could not have null values.
  • It do not need constructor or destructor and members could be initialized automatically.

   Related Questions in Programming Languages

  • Q : Main uses of Virtual memory Illustrate

    Illustrate the main uses of Virtual memory?

  • Q : Define Double buffering Double

    Double buffering: A graphics method employed to smooth animation. The later version of an image is drawn `at the back the scenes' and then exhibited in its totality whenever the drawing is finished. The supposition is that it will be relatively fast t

  • Q : What is Signal Handler Signal Handlers:

    Signal Handlers: In some operating systems, signal handlers are executed on a thread stack; they “overlay” the current thread execution (which may be used, for example, in combination with setjmp/longjmp to create user-domain lightweight t

  • Q : Define the features of DTD Define the

    Define the features of DTD?

  • Q : Define Octal Octal : Number

    Octal: Number representation of octal is base 8. In base 8, simply the digits 0 to 7 are employed. Digit positions symbolize successive powers of 8.

  • Q : Explain UpdatePanel control Briefly

    Briefly explain about the UpdatePanel control.

  • Q : Explain Abstract Windowing Toolkit

    Abstract Windowing Toolkit: The Abstract Windowing Toolkit (AWT) offers a collection of classes which simplify the creation of applications with the GUI (graphical user interfaces). Such are to be found in the java.awt packages. Included are classes f

  • Q : Explain Counters Counter variables are

    Counter variables are commonly used in many computer applications for different purposes. Here is a typical example where a variable is used to measures the progress of some activity of interest:

    Q : What is an Operator Operator : It is a

    Operator: It is a symbol, like -, = or ?: taking one, two or three operands and yielding an outcome. The operators are employed in both arithmetic and Boolean expressions.

  • Q : What is Protected access Protected

    Protected access: Protected access is accessible to a class member prefixed with protected access modifier. This member is accessible to all classes stated within the enclosing package, and any sub-classes expanding the enclosing class.

©TutorsGlobe All rights reserved 2022-2023.