.


:




:

































 

 

 

 


samp ob (88); // 88




Samp obarr [10]; // 10-

// }

2.2( )

"" -: char *p int len, char*p - , int len - .

: :

( );

"+" ;

, .

, 2 ""( , ), , .

: strcpy() strcat().

char * strcpy(char *sp, char *si) - si sp, ' \0'; sp.

Char * strcat(char *sp,char *si) - si sp; sp.

2.1

, . -, -. .

( UML-)

-   mycl -
: x   : mycl () : mycl (int n) : getx()

 

#include <iostream.h>

class mycl

{ int x;

public:

//

mycl () { x = 0;} //

mycl (int n) { x = n;} //

int getx () { return x; } };

int main ()

{ mycl a1 (5); // 1

mycl a2; // 2

cout << " a1: " << a1. getx () << '\n';

cout << " a2: " << a2. getx () << '\n';

return 0; }

a1: 5

a2: 0

 

 

2.2

, . , :

Ø ;

Ø .

+ , () .

( UML-)

-   String -
: s : len   _ friend: operator + ()

 

#include <stdio.h>

#include <string.h>

const LEN = 80;

class String {

public:

char s [LEN];

int len;

friend String operator + (String S1, String S2);

};

String operator + (String S1, String S2)

{String TmpS;

if ((TmpS.len = S1.len + S2.len) >= LEN)

{ TmpS.s[0] = \0; TmpS.len = 0;}

else

{ strcpy (TmpS.s, S1.s); strcat (TmpS.s, S2.s); }

return TmpS;

}

void main ()

{ String S1, S2, S3;

strcpy (S1.s, - );

S1.len = strlen(S1.s);

strcpy (S2.s, !);

S2.len = strlen(S2.s);

printf( : \n %s \n %s \n %d %d \n, S1.s,S2.s, S1.len, S2.len);

S3 = S1 + S2; // , : operator + (s1, s2);

printf( : \n %s\n %d \n, S3.s, S3.len);

}

.

:

!

22 15

:

!

37

.

  1. . :

a) () ;

b) ;

c) ( %);

d) .

. .

  1. __, :

a) ( >>);

b) ( <<);

c) ( []);

.

  1. __, :

a) ( +=);

b) ( +);

c) ( -=);

.

  1. . :

a) ( = =);

b) ( -);

c) ( ~).

strset () , .

.

  1. _, :

a) ( +);

b) ( = =);

c) ( -);

d) , - ( /);

e)

f) at (char *substr, char *dest, int i), i- substr dest.

.

  1. //. :

a) ;

b) ;

c) , ( %).

. .

  1. .... ( 24):

a) ;

b) ;

c) ;

d) , , ( %).

. .

  1. . :

a) () ( +, -);

b) ( *);

c) det () ;

d) ort () ;

e) transp () .

.

  1. . :

a) ( >>);

b) ( <<);

c) ( [] []);

d) revers () ;

e) self_value () ;

f) self_vector () .

.

  1. , :

a) ;

b) ;

.

 





:


: 2016-12-31; !; : 493 |


:

:

: , .
==> ...

2030 - | 1663 -


© 2015-2024 lektsii.org - -

: 0.014 .