Docsity

C++ Programing language, Cheat Sheet of Programming Languages

Partial preview of the text

Download C++ Programing language and more Cheat Sheet Programming Languages in PDF only on Docsity!

Pa sLogrammming. With. Ctt (Case and color sengitive aan Lan quag « e) FE Regufrommnnt 5. _ _ © C © - C ° bi } 5 o ig 3 } t , rs Mpnaovel “iohguton sine enti htleaaiin language ° Turbo C3 - Al sules will be followed according to torbo C3 © Borland ¢ Q) Digits s Oto 4 3) _Albhabots ¢ A to Z and a to 3 4) Symbols £ - pre- brocessor directive ~_ semi-colon / Terminator operator : = ¢olon = __S¢tpbe resolution oberator /membershib oherator a? = Comma. ols: <= ia ee Curly braces aben and clos 2 () = harenthesfc ee LJ = Avbsut pt operator ——____— operator /Jasertion_operator___—_———~ >? = Spput— Onstant those _quantittes whose value cannot ———be__changed__doring the. executfon oh tne <*_=_Ovtput operator _/ Eatractfan_operator.— ——$ Program. 44 = logic | AND i Wor 4= Logteal Or W°for example = tnt_x = (00-3 ai 1. Logteal NOT ae -——_——— nm. Tide operator ————“ Jarfables £ Those Quantitfes whose value can be <>. Angular brocisets —— changed _durfng__the__execullon_o} the program. 220-0 Condi tfonal operator seve — = + _-__Dot operator /calting operator __ > —____—— BB) Por_example: = fntiasg i te * - _Esterik / reference operator — ala _ _ a 2uttit vy > _-__number—function_operator — ws - | Sirvghure oh Ctt 6 = -__ Assignment ——_____ ! Se a eee _ — tne _— a im pons ereantadl® z= equal = — - t —.U)__ Documentation_(optional)__ 7 = = — ia aaa 1+ '8Ingle_tine chmment (4) 9 6-38 maynard : a Ee —_ le ctt— 65 Keywords “ga oe en es Pe Pa Oates A ee ORO SISTA _ MA)? ca) <5) Tokens & The indfuidual _onit_of 4he programs is _hnown = _as__tobens, — ———_—1@)_Linking__Sectfon_(compuls ory.) ys “Keywords. Keyiords ae Words_,wohiah uso _operatfons 1+ ‘integer ana “+ float 2 floating point ; Ser ae a ee — no vole) Date: 7 / Page: +Structpre £ Callectfon §, different data tyhe.———— @ Dbfect ¢ Obfect fs a unique entity which ts ugod c to access the member the exlating truct comblex. — clas {int reals Int Imag + © SYNTAX = classname obfeckname ¢ i s,4-5,S2 ; ‘Sfor example student ob? 9 = StS. 3 = in C++ a class contain_3_access bec fiers / modifrors _ @_brivate. @ public @_prodected. _+ Clogs > Clace fs a important }eature sh oops. DS er ~-a as Coy defauit? a Cle ic a collectfon 4 different type of obfects ee — __ (instance vactables). sn otber word class fs iQ gs 2 private sin this acces igh eo ____conectfon of data member and member fun Lf ese the eines only Coon't access —in_anather __ ___4t fs denoted by cla beyword class, another sunctinn , main funtion only), —_ ¢ ° - — p> dt _Is_denoted by _ private. Keyurord. «SYNTAX £ class classname $ + ¢ for examble ? class student daka__members state/ properties ——___¢ member tunction /methods / be “ i ut a {_primte : ‘nt Roll 5 char _nome [oly fe __40r example? cla tudent $ = Int __roll_ho + - ul pa Se ee eee arenes _wiithin_a class, har name s vold get ¢) publie _Keyesord y o for examble % la Atudenk £ privi vyake 8 tnt Roltno + § tout <<" Enter stud ant record "s ______cin>>'Rallop=" >> names i —-_ void dis(y) ft at 4 cout <<" Student record" cout << "Roll no" << Roll no <<"namet <—$$$$_$____Id_ disp()——— ee oe Bo ————————— : A _ mith te et = _ aes = ee? - cout << “addition fs"! <name +: cout << " Enter any no" Cout <<"name =" > 4s vd 2: oe _____ cout << "number Ic" << x 3 i void dicp/s) ‘ i as Second 6 $ cout <<""Fnter Rollno' 3 Bek LY Cin >> Rolls Hi cout <<" Roll=" << Rolls Be _# Nested class 2 i void maint) = 2? f_clase declare in another enclosed clase. (clas. i __toithin__o _clnes). —— Sample A's + SYNTAY_2_class classname 4 f A. disp () In cle sname 2 Sample 22 Sample 1 BS -B. enter) 2 class conta # Container Clacc - 4 - _ 4 f private = Doctor D> _? The clage +that can hold a _callectfan 9, +d __items ¢ different objects) ; patient pb ¢ 7 public + vold ccot() + PB _contoerclacs can he implemented with member ; 4uncifon and data: members ‘to oxamine and Deg : sHemove item b. ge! . z: 2 lacs > doctor: 2 ——— void maind. a —___________ private : char name[iol 3 f . public 2 vold get¢) ae — £ Ce Coet() > a cout << "Enter name t" ¢ cin. >>name + cout << "name =" << name $ i 25 Re 80 dlffient classes)-ustng frend Suachion. class patient clase Second ° i : Clase pirat = __private : char name [30] 5 public_2 void ger¢> int_as : Ze" Ent eve > “one eee —pubifc 2 void Enter value() Cin >> name f >> "ng at, <> a + 2 £.9, class Demo f a i private :Demn{) si Cout <<" constrpctor" f 3 i _at_Thbec of conctroctore 2 —) Default constructor 2 i —= C= Combfler generating comstructor dol pe Defoult constructor without argument — (= 1 Constructor uith esault argument a i) 7 | ie oe BS: BS 2) Porometerfsed Constructor 3) Coby constructor _) Dynamic Constructor = [42 Pxplicft Constructor |) Compile Qenerating Constructor § — — — —___________ : = dl User not creating any “constrvetor oh class hen__campfler wfll _generote he constructor » Compile _g.c only aUocate the memory foe te | data member atthe ime 4 pbfect decloxanon, _4 “| Date: / / Page: jut without argument on. > on or fc np sevng any e.aigoment then %t is called cpnetyucine uithoutcargument.S_ e SYNTAX £ class nome() = £ body of. constr vector i ; UN o.g, 2 clase Demo i £ private 2 int 23 public ¢ Demo () t w= lo ¢ e 2 if i = -void_disp() f raw eh pened waa 3 ~2_Lonstructor with defavit argument — ae any —conateuctor_raceve —some_arguments 1b =i an Q ontains arg —AL_anuments are inf alue a | ee itialiged pith ap —tybe pcan tructor fs Known as: constrvceor_—ullt a es Swan $¢ clasename (arguments J —defavit argument . a | _ | __ body, construckp r __________ ——__eg : Clase Demo = d —__3—_—_—_ £ ants / a i eee private ? int a,b 5 adepau't aston et gener ca | 2 eg 8 class Sample ——____—— —— public ¢ nemof fot »x=0 int _y= io) = £ - i pa —g= private ? ink o 3 iia. $ = po pute Sample Cink x2 bey J 1 i + 7 os nex! void disp i) : as £ £ : a __void_pisp() — — cour f a £ | Demo _p3__}/ D.«Demo() =| of Sample_S (190)," | D. dlichtr$ = & Disb(o$ i oo a el = Dectructor_Is used to dectroy the Object ¢) the —____ Keyword _expifdt (before tnnstructor name). By = clace, [the conctructor, the destructor tsa aria +t ef nombel § inctfo 5) ss —making_0._conetructor _expiftt woe 4 nose __name_t amedac compiles to cou the expitdtt constructor, It te denoted t | clacename but _proceged by tht ape tfide operator hy expitclt (2) Keyword. Cow tw) E _ 2 SYNTAX § explidt classname ) | cSYNTAKE —velasename {-) tines! 7 f : i Q, See a4 constructor =e body of Destructor = donk > F al 2 for eg st c= i]: for 0g 1 Clase Sample na & “e{QAP tp Implement expitdt constuctor é i t 6 dass Polnt Sh P eared fi public 2 Sample (int x, int 4) : ; ~ — —_ Teh { — fata spy —_— = _ oe niet ae: i mee 7 i Sampt (10,20) ~ aa Sample S:Dtep¢o 3 I z = f : om 3 Sambie §, (100, #0023 = 7 4 Gx {Output a=10 1. Disp) > Error