.


:




:

































 

 

 

 





18

. .

. 1

. 1

. 5

. 7

.. 7

. 8

. 10

. 11

. 12

. 15

. 15

. 17

. 17

. 17

. 19

. 19

. 20

. 20

. 21

. 22

( , ) , struct , , ( ), , .

( , ) , . , . . .

 

 
 


struct date{ int day; int month; int year; char mon_name[10]; }; ()     (, -)
( , )

 

( , ):

struct pattern_name { type1 field_name1;
type2 field_name2;
..
typeN field_nameN;

};

, :

struct pattern_name { type1 field_name1, field_name2;
..
typeK field_nameN;

};

:

  • pattern_name , ;
  • type1, type2, typeN ;
  • field_name1, field_name2, , field_nameN , .

++ .

 

:

//1

struct PointRecType //

{ int x, y;

};

//2

struct ColorPointRecType //

{ int x, y;

unsigned color;

};

//3

struct Book //

{

char name [20];

chat title[44];

int year;

float price;

};

//4

struct Auto //

{

char fio[40]; //

char adres[60]; //

int nomer; //

char marka[20]; //

};

//5

struct Student //

{

unsigned short gruppa;

char fio[20];

unsigned short ocenki[KOL_OC]; //

};

//6

struct Rectangle //

{

int left; //

int top;

int right; //

int bottom;

};

//7

struct Box //

{

double length; //

double width; //

double heigth; //

};

:

( , );

 

s1 s2 Student :

Student s 1, s2; // struct

 

++ . :

struct Book { char name[20];

char title[44];

int year;

float price;

} first_book, child_book, dog_book [4], *ptr_book;

 

. . :

 

struct { //

int pole1;

double pole2;

char *pole3;

} a, b, *pb=&b, *pc, &refa=a, &refb(b);

 

, , .. , . , ( ) , ( ) 1.

new:

ptr_book = new Book; // Book
// .

. refa refb.

:

_. __
//. ()

___. __

(*___). __

, (*) , .

 

:
(* ___ ). __

->:

___ -> __

// -> ()

 

:

struct date{

int day;

int mes;

int year;

char mon_name[10];

} x, y, *ptr_date= &x;

 

:

(*ptr_date).year ptr_date->year

(*ptr_date).mon_name[0] ptr_date->mon_name[0]

 





:


: 2016-10-06; !; : 440 |


:

:

: , .
==> ...

1460 - | 1434 -


© 2015-2024 lektsii.org - -

: 0.077 .