0% found this document useful (0 votes)
7 views19 pages

Lectures 1 2

CS103 is an introductory course on Object-Oriented Programming (OOP) taught by Dr. M Kiran Reddy in Spring 2025, requiring basic programming skills in C as a prerequisite. The course covers various modules including C++ concepts, classes and objects, memory management, and file handling, along with evaluation criteria based on attendance, theory, lab exams, and real-world implementation. Recommended textbooks include works by E Balagurusamy, Robert Lafore, and Bjarne Stroustrup.

Uploaded by

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

Lectures 1 2

CS103 is an introductory course on Object-Oriented Programming (OOP) taught by Dr. M Kiran Reddy in Spring 2025, requiring basic programming skills in C as a prerequisite. The course covers various modules including C++ concepts, classes and objects, memory management, and file handling, along with evaluation criteria based on attendance, theory, lab exams, and real-world implementation. Recommended textbooks include works by E Balagurusamy, Robert Lafore, and Bjarne Stroustrup.

Uploaded by

Aryaman Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

CS103 - Introductin to Object Oriented

Programming
Instructor: Dr.M Kiran Reddy, Assistant Professor, CSE
Spring 2025
Prerequisites

• Basic programming skills using C

Schedule

• Tuesday -> 10:00 -10:55 AM


• Thursday -> 12:00-12:55 PM
• Friday -> 9:00 - 9:55
• Wednesday -> 16:00 - 17:25 PM (LAB session)
INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

MODULE-1:
Introduction, POP vs OOP, Benefits of OOPs, C++ concepts: Intro, preprocessors, namespace, syntax, input/output, comments, keywords
and identifiers, variables-literals-consonants, data types, type modifiers, operators, relational and logical operators, conditional statements,
loops, functions, arrays & strings, pointers and references, structures & enumerations.

MODULE-2:
Class and objects, Constructors and destructors, Access specifiers, Static Data Members, Static Member Functions, Friend Functions,
Arrays of objects, Objects as function arguments, Encapsulation, Abstraction, Inheritance: types (Single, multiple, multilevel, hierarchical,
Hybrid), Overriding inherited methods, Polymorphism: static vs dynamic, Operator overloading (ad hoc polymorphism), Method overload
(compile time polymorphism), and Method overriding (run-time polymorphism).

MODULE-3:
Introduction to Memory management, new operator and delete operator, dynamic memory allocation in arrays. Memory Allocation for
Objects, Pointers to objects, ,Pointers to Derived Classes. File handling, Exception handling, templates, standard template library -
containers, iterators, algorithms. Array of vectors, Vector of vectors.

Text/Reference Books

1.Object Oriented Programming with C++ by E Balagurusamy.


2.Introduction to Object oriented programming in C++ by Robert Lafore.
3.C++ Primer, 5th Edition by S. B. Lippman, J. Lajoie and B. E. Moo, Pearson Education.
4.Programming: Principles and Practice Using C++ Second Edition Bjarne Stroustrup.
5.Effective C++: 55 Specific Ways to Improve Your Programs and Designs.
Evaluation Pattern
• Attendance - 85%
• Theory exam - 50%
• Lab exam - 35%
• Real world implementation of C++ concepts - 15%

• PASS (> 25) and A (>85)


Introduction
Programmers write instructions in various programming languages to perform their
computation tasks such as:

• Machine Level Language.


• Assembly Level Language.
• High Level Language.
program Add
Introduction // Input: Stored in memory location 00
and 01
Machine Level Language:
// Output: Sum of two integers 5 + 8 = D
• Machine code or machine language is a set of
saved in memory location 02.
instructions executed directly by a computer’s // Remarks:
central processing unit (CPU). // ----------------------------------------------------
• Each instruction performs a very specific task, -------------------------
such as a load, a jump, or an ALU operation on
a unit of data in a CPU register or memory. 00: 0008 (0000 0000 0000 1000, 8)
• Machine languages represent data and
01: 0005 (0000 0000 0000 0101, 5)
information using binary (1s and 0s), 02: 0000 (0000 0000 0000 0000, 0)
octadecimal, and hexadecimal formats.
10: 8A00 R[A] <- mem[00]
11: 8B01 R[B] <- mem[01]
12: 1CAB R[C] <- R[A] + R[B]
13: 9C02 mem[02] <- R[C]
14: 0000 halt
Introduction
Assembly Level Language: An assembly language (or assembler language) is a data segment
low-level programming language for a computer, or other programmable device, a db 09h
b db 02h
in which there is a very strong (generally oneto-one) correspondence between c dw ?
data ends
the language and the architecture’s machine code instructions. code segment
assume cs:code, ds:data
start:
Assembly language is converted into executable machine code by a utility mov ax,data
mov ds,ax
program referred to as an assembler; the conversion process is referred to as mov al,a
mov bl,b
assembly, or assembling the code. add al,bl
mov c,ax
int 3
code ends
end start

8086 Assembly program


Introduction
High-Level Language:
1. Enables developement of program in much simpler programming context.
2. Independent of computer’s hardware architecture.
3. Focuses more on the programming logic rather than the underlying
hardware components such as memory addressing and register
utilization.

The high-level programming languages are broadly categorized into two categories:

• Procedure Oriented Programming (POP) language.


• Object Oriented Programming (OOP) language.
Difference between POP and OOP

POP OOP

Program divided into small parts called Program divided into small parts called objects
functions
Follows top-down approach Follows bottom-up approach

No access specifiers Access specifiers like private, public etc

There is no data hiding mechanism Data can be hidden using encapsulation

Operator overloading is not allowed Operator overloading is allowed

Does not support polymorphism Method overloading and overriding are possible

Does not support code reusability Supports code reusability

Ex:- C, FORTRAN, Pascal Ex:- C++, Java, Python


Simple C++ Program : What happens in the
background
C++ program to print circumference of circle

#include <iostream>
#define PI 3.14
using namespace std;
int main()
{
int radius = 6; // Intialize radius
double c = 2*PI*radius; // Calculate the circumference of the circle
cout << "The circumference of the circle is:" << c << endl; // Print the circumference
return 0;
}
Execution of C++ code
Source code
(.c file)

Preprocessor
(expanded code *.i file)

Compiler
(Assembly code *.s file)

C/C++ Compiler 10010 Assembler


Program 00101 (object code *.o file)

Linker
Executable (*.exe)

Loader
Preprocessor
Pre-processing phase includes:
1. Removes the comments and unnecessary white-spaces from the program.
2. Expands the Preprocessor directives such as macros, conditional compilations, expansion of
included files.
3. In principle, a clean C++ source module - without any “#” directives, comments is obtained as
output.
4. This step generates an intermediate file example.i, which can be obtained using the code

g++ -E example.cpp -o example.i


Compiler
• Checks for errors (such as syntax errors and compile-time errors) that violates the rules of c/c++
• If there are no errors then compiler converts example.i -> example.s, which in an assembly-level
code.
• The compilers have a machine dependent part, which changes the source code to assembly
language code based on the target architecture.

g++ -S .\example.i -o example.s


Assembler
• Converts assembly level code line-by-line into object code (machine level
code), which is understandable by computer.

• The converted code is stored in example.o file i.e. example.s -> example.o

• Object files from this process can be placed in archives called static libraries
for later use; you don’t have to recompile all your source files if you change
only one file.

g++ -c example.s
Linker
• The linker is responsible for creating a coordinated and functional executable from multiple
object files, ensuring that all parts of the program can work together seamlessly.

• The main functions of linker are : (i) Combining object files, (ii) Symbol resolution, (iii)
Address Binding, (iv) Relocation and (v) Handling libraries.

• Generates an executable file that contains binary code carrying instructions for a CPU to run
a program. Example.o to out.exe

g++ example.o -o out


ALL in one go !

g++ example.cpp

g++ example.cpp -o out1 (to get executable file with custom name ‘out1’)
Loader
• The loader is a part of operating system (OS) and its main function is to load the executable file
into memory, allocate memory space for the program code and data, and set up the initial state of
the program.

• The loader operates at run-time and loads the program into the main memory for execution of
that program.

• It performs the process of address binding, which involves associating symbolic addresses used in
the program with actual memory addresses. This can include absolute, relative, or dynamic
addressing, ensuring that the program can access its required resources correctly.

• The loader detects errors such as insufficient memory, incompatible executable file formats, and
missing dynamic libraries.

• Initializes the program counter to point to the entry point (usually the “main” function) of the
program.
• After loading:

The CPU starts executing the machine code instructions in the


loaded program, following the program’s control flow and
performing any necessary input/output operations. The program
may also load and utilize dynamic libraries during its runtime.

Once the program completes its execution, it generally returns


control to the OS and frees up the memory resources it utilized. The
OS then performs any necessary cleanup tasks and ends the process.

You might also like