.


:




:

































 

 

 

 


є

. 1 (2010-11-12 .)

-----------------------------------------------------------------------------

 

, .. 2

. 2

.. 3

(3 , 32 ) 4

1. ++. . (4 ) 4

2. . (4 ) 10

3. . , (4 ) 13

4. - . (4 ) 14

5. . (4 ) 15

6. . (4 ) 16

7. (4 ) 17

8. - (4 ) 18


,

 

1. .. /++. . .: , 2001. 460 .

2. . ++, 3- . .: -, 2003. 688 .

3. , . UML. / . . - .: , 2007. - 296 .

4. .. : . .: , 2004. 527 .

5. 19.701.

6. - (. - ).

7. . . ++. ., , 1991. 352 .

8. .. . . .: , 2003. 384 .

9. . /++, 3- . .: . , 2003. 432 .

10. . . - .: , 1979.

11. .., .. ++. - : . .: , 2004. 265 .

12. , . / . , . , . . - .: , 2002. - 496 .

13. . UML 24 . .: . , 2002. 352 .

14. , . UML / . , . , . . - .: , 2005. - 736 .

15. UML [ ]. - 2007. - : http://www.uml.org.

 

, , .

:

1. .

2. , , .

3. ( ).

4. ( ).

5. ( ).

6. .

7. .

8. .

1. .

2. .

3. ( ).

 

2-8 . ( ) .

.3 , . , ( ) . , , , . .

.4 : UML; ( ) (, ) , (, ), (, , - ).

.5 : UML ( ) .

.6 () () (). , , , , ( ), , , .

.7 () [ 19.701], UML.

.8 .

 

1. .

2. . (, ) . (, ) .

3. , , .

4. . - . (. ).

 


(3 , 32 )

 

++, Windows-

1. ++. . (4 )

 

1. ( Microsoft Visual Studio). 19.701 .

2. ++ (, 1 2) .

3. , UML, .

(, - 4, , )

1 ( ).

, , , , , , , , ..

. .

1. 2-3 - ( ).

2. ( ).

3. , (, TO_SET(), TO_SHOW() ..).

4. ( =, ).

2 ( ).

, , ; ; ; ..

2.

. .

C++ - . , , , ( ). , . C++ . , , , ( ) , , dial, answer, hang_up. , .

:

- , .

- C++ .

- , , . () (), .

- .

- , .

- ( , ) .

- . , , class:: function.

:

- , ().

- , , , int, char . .

- , .

- - , .

 

. , , . - , , , . , - , , . C++ . , . , , , .

. - . , C++ , , :

 

class class_name

{

int data_member; //

void show_member(int); // -

};

 

( ), :

 

class_name object_one, object_two, object_three;

 

employee, :

 

class employee

{

public:

char name[64];

long employee_id;

float salary;

void show_employee(void)

{

cout << ": " << name << endl;

cout << " : " << employee_id << endl;

cout << ": " << salary << endl;

};

};

 

-. public . 22, (private) {public), , . , , , . () , :

 

employee worker, boss, secretary;

 

EMPCLASS.CPP employee. , show_employee :

 

#include <iostream.h>

#include <string.h>

class employee

{

public:

char name [64];

long employee_id;

float salary;

void show_employee(void)

{

cout << ": " << name << endl;

cout << " : " << employee_id << endl;

cout << ": " << salary << endl;

};

};

 

void main(void)

{

employee worker, boss;

strcpy(worker.name, "John Doe");

worker.employee_id = 12345;

worker.salary = 25000;

strcpy(boss.name, "Happy Jamsa");

boss.employee_id = 101;

boss.salary = 101101.00;

worker.show_employee();

boss.show_employee();

}

 

, employee worker boss, . show_employee.

C++ . , , , . . , . , . , . - .

employee ( (inline) ). . , . :

 

class employee

{

public:

char name[64];

long employee_id;

float salary;

void show_employee(void); |>

};

 

, (::). :

 

void employee:: show_employee (void) //-------------->

{

out << ": " << name << endl; cout << " : " << employee_id << endl;

cout << ": " << salary << endl;

};

 

, (employee) (::). CLASSFUN.CPP show_employee , :

 

#include <iostream.h>

#include <string.h>

class employee

{

public:

char name [64];

long employee_id;

float salary;

void show_employee(void);

};

void employee::show_employee(void)

{

cout << ": " << name << endl;

cout << " : " << employee_id << endl;

cout << ": " << salary << endl;

};

 

void main(void)

{

employee worker, boss;

strcpy(worker.name, "John Doe");

worker.employee_id = 12345;

worker.salary = 25000;

strcpy(boss.name, "Happy Jamsa");

boss.employee_id = 101;

boss.salary = 101101.00;

worker.show_employee();

boss.show_employee();

}

 

C++ (), , . . , . , , , . , . , , .

, :

 

return_type class_name::function_name(parameters)

{ // }

 

PEDIGREE.CPP dog, show_breed. . dog :

 

#include <iostream.h>

#include <string.h>

class dogs

{

public:

char breed[64];

int average_weight;

int average_height;

void show_dog(void)

};

 

void dogs::show_breed(void)

{

cout << ": " << breed << endl;

cout << " : " << average_weight << endl;

cout << " : " << average_height << endl;

}

 

void main(void)

{

dogs happy, matt;

strcpy(happy.breed, "");

happy.average_weight = 58;

happy.average_height = 24;

strcpy(matt.breed, "");

matt.average_weight =22;

matt.average_height = 15;

happy.show_breed();

matt.show_breed();

}

1. .

2. UML [. . UML. . 3, . 30-32, 6, .77-80].

3. - , , . ( UML) !


 

2. . (4 )

1. .

2. .

( 5 , ).

.

.

C++, .

. C++ , , .

*, . C++ . , , , . , , , .

, . ( ), add_values, , , . , add_two_values add_three_values. float, . , C++ . C++ , , . .

:

"" . .

, .

C++ , , .

, .

, add_values. int. . C++ , :

 

#include <iostream.h>

int add_values(int a,int b)

{ return(a+b);)

 

int add_values (int a, int b, int c)

(return(a+b+c);)

 

void main(void)

{

cout<<"200+801="<<add_values(200,801)<<endl;

cout<<"100+201+700="<<add_values(100,201,700)<<endl;

}

 

, add_values int, . - , , . , , .

MSG_OVR.CPP show_message. show_message , . , :

 

#include <iostream.h>

void show_message(void)

{

cout << " : " << " C++" << endl;

}

 

void show_message(char *message)

{

cout << message << endl;

}

 

void show_message(char *first, char *second)

{

cout << first << endl;

cout << second << endl;

}

 

void main(void)

{

show_message();

show_message(" C++!");

show_message("B C++ !"," - !");

}

 

, . , , day_of_week, (0 , 1 ,..., 6 ). , , , , :

 

int day_of_week(int julian_day)

{

//

}

 

int day_of_week(int month, int day, int year)

{

//

}

 

 

1. .

2. .

3. ++ , .

4*. .3, .

* - !


 

3. . , (4 )

1. .

2. ( , , ) .

.

.

1. .

2. , .

3. , .

4. ++ , .


 

4. - . (4 )

1. friend- .

2. .

.

1. friend-.

2. .

3. .


5. . (4 )

1. .

2. .

3. .

4. UML.

. .

1. UML [. . UML. . 3, . 36-37].

2. . , . 1-2 (, TO_SET(), TO_SHOW() ..). ( UML) !

3. ++ , .

4. . .. : - public- ; - public- public- . ( .), ( ->) 6 .


6. . (4 )

.

.

.

1. .

2. .


7. (4 )

1. .

2. .

3. .

4. .

.

1. .

2. .

3. .


8. - (4 )

- - C++ ( iostream).

.

- (. - ).

1. - - C++. , , .

2. get(), getline().

3. put().

4. -.

5. .

6. ( ) .


 

 

- 1. ! [. _1] ( ):

) ;

) , ( ). ;

) , ;

) , (-) (-). 3 , . .

.

 

- 2. ! () (, , , ..). , : - ( ); - ( , .. ); - ( , .. ) ; - ( , ) [. _2] ( ).

:

) . ( -) ( - ). ;

) ( - );

) . ( 2,), -, , -, ;

) ( ). ;

) -. InputData; InputData ; ( ) OutputData; - OutputData. ( ), , ( ).

.

 

- 3. , 1-3 3-10 , . , , , (, , , , ), (, , , ), , .. ( ).

:

) ( , , , , , ..); , . . ;

)* .

.

 

4. :

) ;

) .

. .

 

5. .

. .

 



<== | ==>
. |
:


: 2016-11-12; !; : 290 |


:

:

, .
==> ...

1730 - | 1555 -


© 2015-2024 lektsii.org - -

: 0.264 .