Programming and Graphics

(Kiana) #1

36 Introduction to C++ Programming and Graphics


and the array of strings:


string A[9][38];

Successiverowsof a matrix are stored in consecutive memory blocks.


Data structures


Consider a group ofMobjects,

o 1 ,o 2 ,...,oM,

agroupofNproperties,
p 1 ,p 2 ,...,pN,


and denote thejth property of theith object by:


oi.pj

The individual properties of the objects can be accommodated in a data
structure defined, for example, as:


struct somename
{
int p1;
float p2;
double p3;
double p4;
}
o1, o2, o3;

Alternatively, we may define a data structure in terms of the properties
alone by declaring:


struct somename
{
int p1;
float p2;
double p3;
double p4;
};

and then introduce members by declaring:


somename o1;
somename o2, o3;

Objects and properties are threaded with a dot (.) into variables that
Free download pdf