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
.
- . :
a) () ;
b) ;
c) ( %);
d) .
. .
- __, :
a) ( >>);
b) ( <<);
c) ( []);
.
- __, :
a) ( +=);
b) ( +);
c) ( -=);
.
- . :
a) ( = =);
b) ( -);
c) ( ~).
strset () , .
.
- _, :
a) ( +);
b) ( = =);
c) ( -);
d) , - ( /);
e)
f) at (char *substr, char *dest, int i), i- substr dest.
.
- //. :
a) ;
b) ;
c) , ( %).
. .
- .... ( 24):
a) ;
b) ;
|
|
c) ;
d) , , ( %).
. .
- . :
a) () ( +, -);
b) ( *);
c) det () ;
d) ort () ;
e) transp () .
.
- . :
a) ( >>);
b) ( <<);
c) ( [] []);
d) revers () ;
e) self_value () ;
f) self_vector () .
.
- , :
a) ;
b) ;
.