tamil compute book - c++

of 241 /241

Author: sakthivel

Post on 12-Nov-2014

8.265 views

Category:

Documents


16 download

Embed Size (px)

DESCRIPTION

Tamil Compute Book - C++

TRANSCRIPT

I F 2005, F I , , , . A M, , I , . A CK M, , . FF E , FK , . M, , I , . e M, , . FF F Aw, H LI, . F FF M, , T R H LI, . CK CL , P, Hv, . M :

K: I O M , I 70 T.v.. O C.

i

QQ M b HC Q EPJ MJP b G . EP M. M A. - C EP, C PM, E, G HC bF A F . N, E O Q M . Q, Q , F GM . CF PM. A E J, QK O A. , A O M , G A G , I E GA. K, H F. , EP P A. , , EP O J . EP N G A. , KP N G N PA. G N . C PM , C E . C, N . G N, G, b G O K . C-N . , N. , b A . C-N F N. F C-NJ C++ N P MA. C++, G (Object Oriented Programming

ii

-OOP) P F . , N G N A. C++ N , N (OOP) N AM.

C++ NO (Object) P A A A. , GO , , . QA , HC Q O F A. A G A HC b A. C++ NJ, G C, A K AP J A. O, M G FJ . C++ G A I MM L F F I. N F MA. K M M (Q ). O N P P M. CK, e, O M O IC E P KM .

F e

.I

v

1 C++ NJN G (Object Oriented Concepts using C++)1.1 G N(Object Oriented Programming Language) 1.2 (Polymorphism) 1.3 K (Inheritance)

11 4 5 6 9

1.4 : i c JC M

2

C++ NJ (Overview of C++)2.1 2.2 2.3 2.4 C++ P F (C++ Character Set) (Data Types) P (Variables) JC M

1010 10 30 41 51

3

(Basic Statements)3.1 3.2 3.3 3.4 3.5 3.6 k / Of C++ G - C++ GL (Declaration Statements) FH (Assignment Statements) (Control Structures) G JC M

5454 56 57 58 59 88 89

4

(Functions)4.1 4.2 P (Function Prototype) 4.3 P 4.4 P H 4.5 FH FH

9494 96 98 99 109

v

4.6 inline 4.7 PO (scope) MF JC M

112 114 118

5

M - E(Structured Data Type - Arrays)5.1. 5.2. K E (Single Dimensional Array) 5.3 (Strings) 5.4. K E (Two-Dimensional Array) 5.5. O E JC M

124124 126 131 136 143 145

6

(Classes and Objects)6.1 - 6.2 6.3 (Data Abstraction) 6.4 6.5 6.6 6.7 M 6.8 G W 6.9 static 6.10 O E JC M

151151 151 154 154 155 156 157 159 160 164 164

7

(Polymorphism)7.1 7.2 EI (Function Overloading) 7.3 P EI (Operator Overloading) JC M

169169 169 174 182

v

8

A NH(Constructors and Destructors)8.1 8.2 A (Constructors) 8.3 AJ 8.4 AJ EI (Constructor Overloading) 8.5 A MF 8.6 NH (Destructors) 8.7 NH MF JC M

184184 184 185 185 190 190 191 192

9

K(Inheritance)9.1 9.2 9.3 9.4

193

193 KF 194 M 194 G / A H (Visibility Mode / Accessibility Specifier) 197 9.5 KF 201 JC M 204

10

F e EPJ (Impact of Computers on Society)10.1 10.2 EP 10.3 EP i 10.4 iL A E 10.5 MJ EP 10.6 A EP 10.7 EP 10.8 J EP 10.9 G O JC M

208208 209 209 211 213 215 216 217 218 218

vi

11

N (IT Enabled Services)11.1 11.2 11.3 11.4 11.5 I- (e-Governance) M (Call-Centres) (Data Management) (Medical Transcription and Tele-medicine)

219219 220 222 222 224 225 227 227

11.6 EP (Data Digitization) 11.7 JC M

12

EP P(Computer Ethics)12.1 12.2 12.3 12.4 (Data Security) EP (Computer Crime) (Cracking) , , JC M

228229 229 232 232 232

vii

1C++ NJN G (Object Oriented Concepts using C++) 1.1 G N(Object Oriented Programming Language)

C b M EP MA. C b EP G (Programs) (Application Software) AA. G G NJ A. EP G, k O e A. k , EP GL Of A. G NO k Of P (Variables) . k (Data Types) . O e G EP P (Control Statements) . G N J A. CL bP A. b C I CA , G N O F A A. F G N . EP P O N . H, C bM, (data), (operations) HK , Q J C b FM . C++ G N, J C HC b, Q 1

. , Q HC b , b Q A. H A. F P. K O F O K A F J C b F I P AA. Oe G , C b N G A. O Q, O F, H , G C HKA. - - (object) A. , O H A. EP GL A. , EH (Calculator) . G (State), H (Behaviour) A . G , c , , CF, P PA. H , , N, GF I, G N A.

FO , , F M C F

1.1 EH

2

G NJ EH A: - EH :Number1,result, operator, Number_backup

:Additon() Subtraction() Erase_Memory() Display_Result()

, A . , PH , G . F (Encapsulation ) N A. H F A. A , , , , L G H A O . M EP GL P F A. GO A E (Objects) OF.

3

A :Account number long int Name char[15] Opening balance float; Account type char

A :Date_of_birth char[10] Name char[15]; Class, sec char[4]; Marks float

:Accept_Details() Display_Details() Update_opening_balance() Withdrawls() Deposit()

:Accept_Details() Display_Details() Total() Average() Grading()

1.2 (Polymorphism) , , , E . J. :Draw_Square() Read side Drawrequired lines Draw_Rectangle() Read length, breadth Draw required lines Draw_Circle() Read radius Draw Draw_Arc() Read Start_angle, End_angle,radius draw

W : Draw (side) - Draw (length, breadth) - Draw (radius) - Draw(radius, start_angle, end_angle) - Draw( ) k A. . J k Draw() P . Draw( ) kO J O (Polymorphism) A. F O F A.

4

1.3 K (Inheritance) (Class) M A G AA. H O (Template) . , JKO MA A. , M A. M , , G-c , C, HK P. M . , , N, A MO A. , , MO . MO , . J K Q E . , , G-c , C, A , M M A A. A:Class animal : Features : eyes, skin, habitat, food Functions : Reproduction() living_style() prey_Style()

Mammals Young_ones Mammary_glands Functions: Parenting(); Reproduction_style()

Birds: Young_ones; Feeding_Style; Skeleton_hollow; Functions: Migration();

1.1 K

M (base class) A. , M (derived classes) A. M F I. K Q M .

5

M K (Inheritance) A. K M M IMA. G PJ (Code Reusability) FA.

GF :GO, (Class) M A. H O ( O ) . O I O A. (Data Hiding) (Data Abstraction) A. (Function) P (Operator) F (Polymorphism) C (Complexity) A. K (Inheritance), M J M NA. P (Code Resuability) FA. O, H P A F N A.

1.4 : i ci c G . F c OPO O cK , cK A GL . G M: F G c FHO (Taps) E, FHJ N O cK , F cK . FH . , c 6

/ G PH M 0 cK A . E FH , FH F, E, cK P, c A A P P (Instance Variables) . FH A: :Tap_open, Qty_water, Water_source

1.2 i c

:Start() Stop() 1.3 FH

cK A G, FH c MQA c (Water pipe) . c FH A (Building) . c Q, F FHO G P . FE 1.4 - A. 7

i FK c t1, t2, t3 A FH p1, p2, p3 A c

:water_pipe : Thickness, Length, Valves : Water_flow() Valve_Status() Time_Taken()

1.4 i c

cK total_amount F,t1.water_consumed()+t2.water_consumed+t3.water_consumed()

A. QQ FHJL cK t1.water_consumed(), t2.water_consumed(),.... P. t1.water_consumed() P1 N cK P. t1 FH cK P1 J bQA. G, F M A . O A. G O A , GL F M A. , k H K A. GF , , A A A. I J , GO O M A. O H M GF PH C .

8

JC MI. G

) )

EP GL ________ A. H ____________________ A. F O F____________________________ A M F M ___________________ A.

) )

II. W M M O:

1. 2. 3.

? F ? KFL A?

III. W FE M

G FK (Data Model) K MA. G E K I . EO M: Name, date of birth, language, nativity. EO E J I M: ) Stores - date of joining, dept, salary ) Scientist - area of specialisation, current project details, paper presentations ) Technician - height, weight, ailments, risk factor, department, wages

9

2C++ NJ (Overview of C++) 2.1 C++ N 1980-O F & F vv (Bjarne Stroustrup) . C++ (C Hv Hv K ) K vC . ++ C NJ I P .

2.2 C++ P F (C++ Character Set)C- N C++ N P F . FL M (Tokens- G P O ) A. P FJ W P A:A........Z, a.......Z, 0........9 +, -, /, *, \, (, ),[, ], {, } =, !=, , ., , , ;, : %, !, &, ?, -, #, =, @

O, A , F F H P. P . M (Tokens) A. M GL eC Q . M 2.1- A.M

C

P PL

P

2.1 MO

G P

2.2.1 C EP NJ GH (Language Compiler) KA C A.

10

C . P . C++ NJ C O 2.1- .auto default friend private static while 2.1 C break delete goto protected struct case do if public switch const else inline return this class enum new signed unsigned continue for operator sizeof virtual

2.2.2 P (Identifiers)P, P (Variables) A. P , F PL A G PA. PJ F WP(Underscore) A, . _test; test; sum12 A P. P H P P .

2.2.3 PL (Constants)PL F M . PL , . PL F . . F O (decimal numbers) . (Integers) I O (floating point) PL .

2.2.4 PL (Integer Constant) PL . HF . + - A P (prefix) . 0 - M (Octal) PL . (-) 010 = 8 ([8]10 = [10]8). 0X F (hexadecimal) . (-) 0XF=15 ([15]10 = [F]16). 11

2.2.5 I O PL (Floating Point Constant)I O PL PJ P. , F, F O, H F, F A F . I O PL PH F, H F A MM. . 58.64 I O () . J W PH: 5.864E1 => 5.864*101 => 58.64 5.864E-2 => 5864*10-2 => 58.64 0.5864E2 => 0.5864*102 => 58.64

I O J PH E e .

2.2.6 P PL (Character Constant)P PL P P . C++ NJ P FJ P (ASCII FJ E/d/H C P) . (tab), HQO (backspace) KF (line feed), FHL (null), H (backslash) A C P M K (escape sequence) PHA. M K H PH. 2.2- M K P .

12

M K\a \b \n \t \v \\ \ () \ \o \X \0

P E L HQO F K/ KF A H / F FHL

2.2. M K P

2.2.6 G (String Literal) G P PO K . G PO E (array of characters) A. G (by default) \0 C P P . F F PA. (-) : testing

2.2.7 P (Operator)P F M G PA. P H O (Operands) e A. : RESULT = NUM1+ NUM2

F, NUM1, NUM2 A H. + M P . = FH(assignment) PJ M M F, RESULT PJ IA. C++ NJ PO 2.3- .

13

[] () . -> ++ &

* + ~ ! size of /

% > < > =

== != ^ | && || ?:

= *= /= += -= %= * # ## A P L (Preprocessor) F . P :

W (Arithmatic) FH (Assignment) K (Component Selection) G (Conditional) (Logical) (Manipulator) H P M (Member dereferencing) G (Memory Management) L (Preprocessor) d (Relational) (Scope Resolution) (Shift) (Type Cast) HO E J P (Unary) (Binary), (Ternary) HK. : P H . P H . P H .

14

P & ! * ++ ~ +

M K F I HG G F

P + * / % > HG & | ^ && || FH = /= += *= %= -= = &= |= d < > = == != . -> ::

2.4() P

G K H

M N eF Q FH FH FH A FH eF FH N FH FH FH HG FH HG FH MCP MK MCP G MK G G GK K K / P

.* P M P G -> * P M ?: P O , FH 2.4() P

15

2.2.7.1 W P (Arithmatic Operators)W P E G A. W PO : P + * / % +=, - = *=, /= %= N eF A FH

W P, PL/P, W P A A, W (arithmatic expressions) A. : a = -5; a = +b; a/=5; (a=a/5) a++; (H I P. a = a+1 G) a- -; (H P. a = a-1 G) ++a; ( I P. a = a+1 G) - -a; ( P. a = a-1 G) a *= 2; (a = a*2 ) a %= 5; (a = a%5) a = b + pow(x,y); (a = b + xy )

P KJ J GA. H, P PH FHA. (association) A. F . E PO 2.6 - .

16

P K ( ), [ ] H ++, ++, +, *. /. % +, -

E E- E- E- E-

F I I I I I

2.6 E PO K

W , W FH K MA.5 + 6/3 = 7 5 6 3

7

5 * 6/3 = 10

17

(5 + 6) /3 =3

k int M 3 . k float Q, M 3.66 A.1 + pow (3, 2) = 10

18

1 + pow (3, 2) * [ (3 + 2) (8 - 7) + 2 ] = 55

I, P C NJ C++ NJ A. P , FH 2.7- .

19

a++

a- F

a = 5; c = a++;

FH 1 I

:c = a; a = a+1;

, c PJ F 5 .++a a- FH 1 I

F

a = 5; c = ++a;

:a = a+1; c = a;

, c- PJ . F 6 .a -a- F FH 1 a=5; c = a--;

:c = a; a = a-1;

c- F ?--a a- FH F a = 5; c = --a;

:a = a-1; c = a;

c- F ? 2.6 I, P

20

2.7- FO PO F ?1. a = 5; b = 5; a = a+b++; 2. x = 10; f = 20; c = x++ + ++f; 3. fun=1; sim=2; final= - -fun + ++sim-fun- -

PJ F_____

PJ F c-_______ x-_______ f-_______

PJ F fun-_______ sim-______ final-______

2.7 O M

2.2.7.2 d P (Relational Operators)F H d P A. d PO : == G > MK < MCP >= MK G 20 500.45 20 ) 1 (500.456 a>A

M0

=5