100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
C++ NOTES FROM HELLO WORLD TO ADVANCED $8.29   Add to cart

Class notes

C++ NOTES FROM HELLO WORLD TO ADVANCED

 2 views  0 purchase
  • Course
  • Institution

THIS DOCUMENT CONTAINS C++ NOTES .FROM BIGINNING TO ADVANCED .WITH PROGRAMS .YOU CAN UDERSTAND VERY WELL.EASY TO READ.

Preview 4 out of 222  pages

  • March 4, 2023
  • 222
  • 2022/2023
  • Class notes
  • Anusha
  • All classes
avatar-seller
UNIT-I
OBJECT ORIENTED THINKING

Q. EXPLAIN ABOUT THE DIFFERENT PARADIGMS FOR
PROBLEM SOLVING
Paradigm definition
A paradigm is a way in which a problem is to be solved.

Evolution of Paradigms
Since the invention of computers, many programming approaches have been
developed. The primary motivation of doing so is to handle the increasing complexity of
programs and to make them reliable and maintainable.

The following are the different paradigms for problem solving,
1. Monolithic programming
 The Monolithic programming paradigm is the oldest.
 It is also known as the imperative programming paradigm.
 The program is written with a single function. A program is not divided into parts
i.e. statements are written in sequence.
 When the program size increases it failed to show the desired result in terms of bug
free, easy to maintain and reusable programs.
 The program control is achieved through the use of jumps i.e. goto statements
 It uses all data as global data which leads to data insecurity.
 This approach is useful for designing small and simple programs.
 Example: ASSEMBLY and BASIC.

2. Structured Oriented Programming
 This paradigm introduces a modular programming concept where a larger program
is divided into smaller modules.
 It also provides flow control statements that provide more control to the user.
 It uses all data as global data which leads to data insecurity.
 Example: ALGOL, Pascal, PL/I and Ada.

3. Procedure Oriented Programming
 It basically consists of writing a list of instructions and then breaking them down and
then organizing these instructions into manageable segments or groups known as
functions.
 In this, the problem is viewed as a sequence of things to be done such as reading,
calculating and printing. A number of functions are written to accomplish these
tasks.




1

,  In a multi function program, many important data items are placed as global so that
they may be accessed by all the functions. Each function may have its local data.




 Examples: C, visual basic, FORTRAN, etc.

Drawbacks
 Global data are more vulnerable to an accidental change by a function.
 In a large program it is very difficult to identify what data is used by which function.
This provides an opportunity for bugs to creep in.
 It does not model real world problems very well. This is because functions are action
oriented and do not really corresponding to the elements of the problem.

Characteristics
 Emphasis is on doing things (algorithms).
 Large programs are divided into smaller programs known as functions.
 Most of the functions share global data.
 Data move openly around the system from function to function.
 Functions transform data from one form to another.
 Employs top·down approach in program design.

4. Object Oriented Programming
 This is the most recent concept among programming paradigms.
 It is an approach that provides a way of modularizing programs by creating
partitioned memory area for both data and functions that can be used as template for
creating copies of such modules on demand.
 The major motivating factor in the invention of object oriented approach is to remove
some of the flaws encountered in the procedural approach.




2

,  Example: Smalltalk, C++, Java, C#, Python, etc.
Features
 Emphasis is on data rather than procedure.
 Programs are divided into what are known as objects.
 Data structures are designed such that they characterize the objects.
 Functions that operate on the data of an object are tied together in the data structure.
 Data is hidden and cannot be accessed by external functions.
 Objects may communicate with each other through functions.
 New data and functions can be easily added whenever necessary.
 Follows bottom-up approach in program design.

Q. WRITE THE NEED FOR STUDING OBJECT-ORIENTED
PARADIGM
 It produces reusable code because of encapsulation and inheritance.
 It promotes efficient design and development of software systems using reusable
components that can be quickly and safely assembled into larger systems.
 The code produced is likely to contain fewer errors because pretested objects are being
used.
 Less maintenance effort will be required by the developer because objects can be reused.
 The data is protected because it can be altered only by the encapsulated methods.
 The storage structure and/or procedures within an object type could be altered if required
without affecting programs that make use of that object type.
 New functions can easily be added to objects by using inheritance.

Q. DIFFERENCIATE BETWEEN OBJECT ORIENTED
PROGRAMMING AND PROCEDURE ORIENTED
PROGRAMMING
S.NO Object oriented Programming Procedure Oriented Programming

1 Emphasis is on data Emphasis is on doing things

2 Programs are divided into Objects Programs are divided into Functions

3 Employs Bottom up approach Employs Top down approach


3

, 4 Modification potential is high Modification potential is low
Data is hidden and cannot be accessed by Data is open and can be accessed by any
5
external functions functions
6 Suitable for solving big problems Not Suitable for solving big problems

7 It needs more memory than POP It needs less memory
Supports Polymorphism, Inheritance, Does not supports Polymorphism,
8
abstraction and Encapsulation Inheritance, abstraction and Encapsulation
Example languages are C,VB,FORTRAN,
9 Example languages are C++, Java
COBOL




Q. WRITE A BRIEF NOTE ON THE FOUR OOP CONCEPTS
1. Abstraction
 Abstraction refers to the act of representing essential features without including the
background details or explanations.
 Classes use the concept of abstraction and are defined as a list of abstract attributes
such as size, weight and cost and functions to operate on these attributes.
 They encapsulate all the essential properties of the objects that are to be created.
 The attributes are sometimes called data numbers because they hold information.
 The functions that operate on these data are sometimes called methods or member
functions.
 Since the classes use the concept of data abstraction, they are known as Abstract Data
Types (ADT).

2. Encapsulation
 Encapsulation is the mechanism that binds together code and the data it manipulates,
and keeps both safe from outside interference and misuse.
 In an object-oriented language, code and data may be combined in such a way that a
self-contained "black box" is created.
 When code and data are linked together in this fashion, an object is created. In other
words, an object is the device that supports encapsulation.
 Within an object, code, data, or both may be private to that object or public.
 Private code or data is known to and accessible only by another part of the object.
That is, private code or data may not be accessed by a piece of the program that exists
outside the object.
 When code or data is public, other parts of your program may access it even though it
is defined within an object. Typically, the public parts of an object are used to provide
a controlled interface to the private elements of the object.

3. Polymorphism
 Object-oriented programming languages support polymorphism, which is
characterized by the phrase "one interface, multiple methods."
 In simple terms, polymorphism is the attribute that allows one interface to control
access to a general class of actions. The specific action selected is determined by the
exact nature of the situation.
4

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller anjivarun2002. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.29. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80435 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.29
  • (0)
  Add to cart