Object-oriented Programming Class A class is away to bind the data and functions together.

When defining a class, we are creating a new abstract data type (ADT). Class specification has two parts: 1. Class declaration 2. Class function definitions Class declaration describes the type and scope of its members. The class functions definition describes how the class functions are implemented. Class class_name { Private: Variable declaration; Function declaration; Public: Variable declaration; Function declaration; }; Keywords: class, private, public      { Private: Char Account type; int acc_no; Float bal Public: Void getdata(); Void display(); }; Private and public are known as visibility labels. Variables declared inside the class are known as data members and the functions are known as member functions. Only the member functions can have access to the private data members and private functions. Public members (both functions and data) can be accessed from outside the class. Binding of data and function together into a single entity is referred to as encapsulation.

Class BankAccount

OOP

Page 1

To access class members we create main () and call class member functions use object. } }. //function decleartion Void putdata(void ) { Cout<<number<<endl. Object_name. BankAccount acc1. OOP Page 2 .e. you can create variables of that type by using the class name. the compiler replaces the function call with the corresponding function code (similar to macros in c). float b). Defining member Functions Member functions can be defined in two ways:   Outside the class Inside the class (inline function) Outside the class Return type class_name :: function_name (argument decleration) { Body of function } :: is called membership label that tells the compiler that the function function_name belongs to the class class_name. Inline functions An inline function is a function that is expanded in line when it is invoked i. Float cost.function_name (argument list). float b). to define the inline function we use inline keyword Ex: inline void Item :: getdata(int a. Once a class is declared. Cout<<cost<<endl.Object is an instance of a class. Public: Void getdata(int a. Inside the class Class Item { Int number.

but its lifetime is the entire program. This is an example of polymorphism in OOP. Cout<<sum(11. int b). we can use the same function name to create functions that perform a variety of different tasks.Note: inline is a request not a command. if a loop. C++ allows overloading of functions i. Generally used to maintain values common to the entire class.  OOP Page 3 .9). o One copy of that member is created for the entire class and is shared by all the objects of that class.3.12) Static data members:   A keyword A static data member variable has certain special characteristics: o Initialized to zero when the first object of a class is created. Cout<<sum(4. or a goto exists. double y). Compiler may ignore request and can treat it as a normal function. int b.8.e. Ex: //Declarations int sum (int a. //Function call Cout<<sum(5. Function contain static variables. int sum (int a. int c). 8. Function overloading Overloading means use the same thing for different purposes. double sum (double x. a switch. Recursive functions. o Visible only within the class.10). Note: there are some of the situations where inline may not work:    For functions returning values.

Friend function definition does not use either the keyword friend or the scope operator (::). int number.b.getdata(100). Friend function is not a member function but has all access rights to the private members of the class. Public: Void getdata(int a) { number=a. b.c. count++.getcount(). } }. //count is initialized to zero a.getdata(300).getdata(200).getcount(). main () { Item a. OOP Page 4 .getcount(). } Void getcount(void) { Cout<<”count:”<<count<<endl.getcount (). a. c. b. } Output: count: 0 count: 0 count: 0 count: 3 count: 3 count: 3 Friend functions The functions that are declared with the keyword friend are known as friend functions. a. c. c.getcount(). b.Class Item { Static int count.getcount().

Usually. Can not be called using the object of that class. OOP Page 5 . use of friend is required. it has objects as arguments. Often used in operator overloading Ex: in a situation where two classes want to share a same function.Characteristics:       It is not in the scope of the class to which it has been declared as friend. because it is not in the scope of the class. Invoked like a normal function. It can be declared either in public or the private section of a class without affecting its meaning.

com ADS Securities ADS-Securities. CITA Accredited.LivingSocial.ae/Dubai Like Confirm Online Off Up Recent Activity Share Share Join Chat Join Chat Search. Commodities. Link Menu 1 ridiculously huge coupon a day. Get 50-90% Looking For Something To Do In Dubai? Sign& Like 50% Off Recent Activity Dubai's best! Get Dubai Activities www.com TranslateDubai Videos 1 www.. C-Theory Posted by Akash Padhiyar SPONSORS Click here to update your status on multiple social networks at once! 3rd Grade Syllabus www.TY BCA C++ C++ C++ 4.2010 Java Exception Handling Interview Java Theory Posted by Akash Padhiyar Insertion Sort Sorting And Searching Posted by Akash Padhiyar Java program for Uniform Resource Java Programs Posted by Akash Padhiyar How to Compile C language Program BCA Stuffs. Futures Dubai? SignUp & Get Free Demo Account! Request a50% Off Freezone eBook Outlet www. CITA Accredited.com Looking For Something To Do In Dubai? SignUp & Get 50% Off Freezone Company in UAE DubaiBusinessAdvi… Looking to incorporate a Freezone Company? Get advice from DBA TAG CLOUD http://bcahub.K12.C++ E book | Object Oriented Programming With C++ By Balagurusamy | Balagurusamy Books | BCA HUB HOME ABOUT US ADMIN CONTACT US OUR SITES GO BCA.MCA 1 COMP C++ Compiler Download C++ Compiler Download Ads by Google Ads by Google by Google E Book PDF E Book PDF E Book PDF C++ Game Programming C++ Game Programming Object Oriented Programming With C++ POSTED BY AKASH PADHIYAR ON AUGUST . Remote Online Learning Dubai Coupons www.8 . Link Menu Translate Videos Coupons Online Activities www.K12..BCA HELP 5.FY BCA 2. US Diploma.com/4-bca-help/bca-e-books/object-oriented-programming-with-c/[4/20/2011 5:24:09 PM] .ae The DubaiCompany in UAE DubaiBusinessAdvi… Looking to incorporate Freezone Dubai. Join Get eBooks & More fora70% Off in Company? Get advice the Group ! from DBA Object Oriented Programming With C++ By Balagurusamy Contents Search GOOGLE SEARCH HERE Search ADVERTISE 3rd Grade Syllabus www.SY BCA 3.LivingSocial.shareittips.TUTORIALS & PROGRAMS 1.. Get 50-90% Off Dubai's best! Dubai Activities www.GROUPON.com K-12 Education.ae Looking For Something To Do In & more.. Trade FX. US Diploma.GROUPON.ae/Dubai 1 ridiculously huge coupon a day.IT HELP 6. Remote Online Learning Search.com K-12 Education.GROUPON.LivingSocial.MCA NOTES.

Be the first of your friends to like this.C++ E book | Object Oriented Programming With C++ By Balagurusamy | Balagurusamy Books | BCA HUB This is a preview.shareittips. · Admin Page · Insights · Error wordpress years old services sagar federal student loan soni toolbars sponsor wordpress years old services sagar FREE UPDATES .Movies. Enter Your Email Address Subscribe Find us on Facebook Login BCA HUB Like Confirm You like HUB.Softwares G Cet Notes IT TIPS Share Bca SHARE IT TIPS Widnows Tips and Tricks One Response to “Object Oriented Programming With C++” ravi says: nice book September 2. · Admin Page · Insights · Error James Quadras likes this.com/4-bca-help/bca-e-books/object-oriented-programming-with-c/[4/20/2011 5:24:09 PM] . 2010 at 7:30 am Leave a Reply Name (required) Mail (will not be published) (required) Website Ads by Google C++ Source Code C++ PDF Library Java C++ Converter C++å¦ä¹ C++ Coding Job Ads by Google C++ PDF Library Java C++ Converter C++学习 C++ Coding Job C C++ Training http://bcahub. Page · You like Page · 855 people like BCA HUB. Nikhil Facebook social plugin Kunal Find us on Facebook BCA HUB Like 854 people like BCA HUB. Umang Abhilash Kalpesh Anadkat Nikhil Mithila Pratik Pradeep Raj Ravi Facebook social plugin BCA-E-BOOKS OUR LINK Akash – InfoTech CHECK THIS Sy Bca Gujarat University Paper 2010 (DFS) Download Shyam Chawda Sir’s Notes Electronic Commerce(BCA Book) Multimedia making it work (BCA BOOK) List of Dos Command – 2 FOLLOW ME Akash Padhiyar BCA HUB | BCA HELP Computer Tips and Tricks Download Free Games.854 people like BCA HUB. The total pages displayed will be limited. Like Confirm You like this.

com/4-bca-help/bca-e-books/object-oriented-programming-with-c/[4/20/2011 5:24:09 PM] .com/ Special Thanks To : Sagar Soni (Author of BCA HUB) Computers blogs D e s i g n : W o r d P r e s s t h e m e s C o d e s u p p o r t C D R a t e s .C++ E book | Object Oriented Programming With C++ By Balagurusamy | Balagurusamy Books | BCA HUB Submit Comment @SHAREITTIPS Hi I Am Akash Padhiyar 19 years old blogger and BCA Student . N E T - T E C I n t e r n e t a g e n t u r s o e g e m a s k i n e o p t i m e r i n g http://bcahub.shareittips. http://akashpadhiyar. wordpress .

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.