Thursday 27 February 2014

What is structure in oops?

Basic concept of  Structure:

Structure is collection of dissimilar data type together.Dissimilar datatype means e.g student id,name,marks,result etc.. combine into one array otherwise use four array.

Structure and Class between one difference
Structure is value type use direct memory.
Class is reference type use dynamic memory


In main method, I can create an instance of this class using new operator that allocates memory for this class and stores the base address of that into  Program type variable.

In the above program, “program student[] s =new student[3]  instruction indicates that both variables of type array three time will point to same memory location .it basically assigns the same memory location into another variable of same type.
   
In general, Class can be used when more complex behavior data. that behavior data to be modified after creating an instance of class,then class is absolute methods.

0 comments:

Post a Comment