SHORT NOTES

OBJECT ORIENTED PROGRAMING AND C++

SYLLABUS:-                                                                                                                                           Credit : 5




1. Introduction to C++ : Object Oriented Technology, Advantages of OOP, Input- output in C++,Tokens,Keywords, Identifiers, Data Types C++, Derives data types. The void data type, Type Modifiers, Typecasting,
Constant, Operator, Precedence of Operators, Strings.
2. Control Structures : Decision making statements like if-else, Nested if-else, goto, break, continue, switch
case, Loop statement like for loop, nested for loop, while loop, do-while loop
3. Functions : Parts of Function, User- defined Functions, Value- Returning Functions, void Functions, Value
Parameters, Function overloading, Virtual Functions.
4. Classes and Data Abstraction : Structure in C++, Class, Build- in Operations on Classes, Assignment
Operator and Classes, Class Scope, Reference parameters and Class Objects (Variables), Member functions,
Accessor and Mutator Functions, Constructors, default Constructor, Destructors.
5. Overloading & Templates : Operator Overloading, Function Overloading, Function Templates, Class Templates.
6. Inheritance : Single and Multiple Inheritance, virtual Base class, Abstract Class, Pointer and Inheritance,
Overloading Member Function.
7. Pointers and Arrays : Void Pointers, Pointer to Class, Pointer to Object, The this Pointer, Void Pointer,
Arrays.
8. Exception Handling : The keywords try, throw and catch. Creating own Exception Classes, Exception
Handling Techniques (Terminate the Program, Fix the Error and Continue, Log the Error and Continue), Stack
Unwinding.

UNIT 1:- INTRODUCTION TO C++

C++ is devloped by Bjarne Stroustrup in 1983 in AT&T Bell laboratry.

Object Oriented Technology:-Object Oriented programming is a programming style that is associated with the concept of Class, Objects and various other concepts revovling around these two, like Inheritance, Polymorphism, Abstraction, Encapsulation etc

.Advantage of OOPs:-Object Oriented Programming has great advantages over other programmingstyles: Code Reuse and Recycling: Objects created for Object Oriented Programs can easily be reused in other programs. Encapsulation (part 1): Once an Object is created, knowledge of its implementation is not necessary for its use.


Different Between POP and OOP

Subject of Difference Procedure Oriented Programming (POP) No. Object Oriented Programming (OOP)
Problem decomposition Decompose the main problem in small parts called functions. 01 Decompose the main problem in small parts called objects.
Connections of parts Connects small parts of the program by passing parameters & using operating system. 02 Connects small parts of the program by passing messages.
Emphasizing Emphasizes on functions. 03 Emphasizes on data.
Use of data In large programs, most functions use global data. 04 Each object controls data under it.
Passing of data Data may get passed from one function to another. 05 Data never get passed from one object to another.
Security of data Appropriate & effective techniques are unavailable to secure the data. 06 Data stay secured as no external function can use data of an object.
Modification of program Modification of a completed program is very difficult and it may affect the whole program. 07 Modifications are easy as objects stay independent to declare and define.
Designing approach Employs top-down approach for designing programs. 08 Employs bottom-up approach for designing.
Data identification In large programs, it is very difficult to find what data has been used by which function. 09 As data and functions stay close, it is easy to identify data.
 
Q:-What is a token in programming?




Ans:- A programming token is the basic component of source code . Character s are categorized as one of five classes of tokens that describe their functions (constants, identifiers, operators, reserved words, and separators) in accordance with the rules of the programming language.
 
Q:-What is Keyword in C++?
Ans:-Keywords are predefined, reserved words used in programming that have a special meaning. Keywords are part of the syntax and they cannot be used as an identifier. ... Here, int is a keyword that indicates 'money' is a variable of type integer. As C is a case sensitive language, allkeywords must be written in lowercase.
auto   const     double  float  int       short   struct   unsigned
break  continue  else    for    long      signed  switch   void
case   default   enum    goto   register  sizeof  typedef  volatile
char   do        extern  if     return    static  union    while

Q:-What is Identifier in C++?
Ans:-An Identifier is a user-assigned program element. ... In C,C++, C# and other programming languages, an identifier is a name that is assigned by the user for a program element such as variable, type, template, class, function or namespace. It is usually limited to letters, digits and underscore.

Q:-What is Data type in c++?
Ans:-Data types simply refers to the type and size of data associated with variables and functions.

HEADER FILES

Header files contain definitions of Functions and Variables, which is imported or used into any C++program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition.

iostream.h:-It is used to handle both input and output.
conio.h:-It is header file of getch(); and clrscr();//Used to clear screen/in turbo c++ only
getch();   :-It is used for hold screen untill input a single character,
clrscr();  :-It is used for clear screen.

C++ is rich in built-in operators and provides the following types of operators:
  • Arithmetic Operators.
  • Relational Operators.
  • Logical Operators.
  • Bitwise Operators.
  • Assignment Operators.
  • Misc Operators.

String is acollection of charecter

char str[6] = {'H', 'e', 'l', 'l', 'o', '�'};
char str[] = "Hello";

Comment in C++

Comment is not exicute in program

Single line comment:-  Single line are used in single line...   syntax:-    // Single line comment
Multiple line comment:- It is used in multiple line of comment... Syntax:-   /* multiple line ........*/

Example 1:- Write a program to display your name?

Notice:-I am use turbo c++ compiler/. so i use #include<iostream.h>
In Codeblock  we use #include<iostream> and we dont use in codeblock ctrscr();...
#include<iostream.h> //Header file of cout and cin
#include<conio.h>  //header file getch(); &clrscr();
int main()
{
clrscr();      // For clear the scren
cout<<"My Name Is Chand Khan";  //print the name
getch();    // to hold screen ..
}

Turbo C++ Keyboard Shortcuts

S.No. Shortcuts keys Action
1. F1 For Help
2. F2 Save
3. F3 Open
4. F4 Go to cursor
5. F5 Zoom
6. F6 Next
7. F7 Trace into
8. F8 Step over
9. F9 Make
10. F10 Menu
11. Alt+X Quit
12. Alt+Bksp Undo
13. Shift+Alt+Bksp Redo
14. Shift+Del Cut
15. Ctrl+Ins Copy
16. Shift+Ins Paste
17. Ctrl+Del Clear
18. Ctrl+L Search again
19. Alt+F7 Previous error
20. Alt+F8 Next error
21. Ctrl+F9 Run
22. Ctrl+F2 Program reset
23. Alt+F9 Compile
24. Alt+F4 Inspect
25. Ctrl+F4 Evaluate/Modify
26. Ctrl+F3 Call stack
27. Ctrl+F8 Toggle breakpoint
28. Ctrl+F5 Size/Move
29. Alt+F3 Close
30. Alt+F5 User screen
31. Alt+0 List all
32. Shift+F1 Index
33. Ctrl+F1 Topic search
34. Alt+F1 Previous topic
35. Ctrl+F7 Add watch

In Codeblock 

Function Shortcut Key
Build Ctrl + F9
Compile current file Ctrl + Shift + F9
Run Ctrl + F10
Build and Run F9
Rebuild Ctrl + F11

Object oriented programming in PDF:-click here

Unit 2

Leave a Reply

Your email address will not be published. Required fields are marked *