0% found this document useful (0 votes)
27 views8 pages

CPP Unit 2lens

Uploaded by

amarjogdande09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
27 views8 pages

CPP Unit 2lens

Uploaded by

amarjogdande09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 8
B.CA, Part -I New CBCS Pattern (Semester: Course Code: CC 203 Course Title: Object Oriented Programming Using C++ Unit - 2 OBJECT, CLASSES & CONSTRUCTOR new user defined data type member Scan bedfined by using a has its body, cota wate: // Data Members ‘Member Functions 1/ Member Functions ’ ‘The private members dita data and prea anctens cannot ose are defined atthe begining ofthe class body with {as private members by default. Each access specifiers le. private, ced follows single colon ( Int emp. code; sharemp.name{i0}: public void getdata wold display Prof.Annasaheb M.Chougule [MMM] ae e Here the dass employee contains two data members and two member fnclone a ‘espectvely. The data members Le emp coe and were as both the member functions are public by specieaaon sed 108d valu from the se les of data members. The data members ofthe employe dl functions of the clase employee, lay) us sed to display the accessible the member ‘+ Arguments toa Function - ta function copes the actual uPe Sh Agument ngs made othe para naet out <<"ARer swap vale of <<< end ) output: Before swap valu of :100 Before swap vale ofb:200 Aft swap, value af :200, ‘Aer srap vue fy 100, Calbyreferencein co+ Example: fale ostream b> Usngrmamespacest Before swap, valve ofa" >ampcadssen ame yee code:="ccamp. code ployename=">emp. 236, “zhember function» [argue ic Emplayeename.=-ccemp name; /*00P Program to get data from user of an employee {aside the clase definition method. */ # include voiding ‘eae ene [cout<<"Fnter code and name ofan employee:="; {Sne>emp.code>>emp name: } oid splay) endl <<"Employee cade ="mos>marts: » “en, out <<\o\nStadent ol number = “ene fut << \nStudent aris = "ccmarks } x vo main) i ‘ca ss: Prof.Annasaheb M.Chougule [MMM] Static Class Members Static Member Function, Static Data Member: re many ase ac menbet fs haya to zero when se or we can intize value also count; //outof the dass we haveto define once bef ‘i other Mf if changes happed 8 ope or any of ebec then it wil revert or updated (sia) Prof.Annasaheb M.Chougule [MMM] -count();// inl value wil be ero isla. output: counter value=0 ‘counter value=0 counter value=0 number=10 sumber=20 rumber=30 counter value=3 static Function Members daring oncom ber Shs A ule member ancion on thematic uneionrae seed [sate memberneton a cigs rom owe te Prof.Annasaheb M.Chougule [MMM] (Sh ta aa .sLage) Prof.Annasaheb M.Chougule [MMM] inate csrvee ide coterie, ee as create. It program to demonstrate the constructor. */ OO ———— [slate Prof.Annasaheb M.Chougule [MMM] 13 Lat, Prof.Annasaheb M.Chougule [MMM] “4 ourpur. yup 0 Sisto ‘BcoNy =0 (state) Prof.Annasaheb M.Chougule [MMM] eT (lee Prof.Annasaheb M.Chougule [MMM] 16

You might also like