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

PPT Lecture 1.2.1

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

PPT Lecture 1.2.1

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

INSTITUTE - UIE

DEPARTMENT- ACADEMIC UNITS


Bachelor of Engineering (Computer Science & Engineering)
Subject Name: Basic Data Structure Using C++
Code:24CSH-103

Topic : class DISCOVER . LEARN . EMPOWER


Basic Data Structure
Using C++

Course Objectives

• To enable the students to understand


various stages and constructs of C++
programming language.
• To improve their ability to analyze and
address variety of problems in C++.
• To understand the concept of data
structures and various operations on
them.
• To understand the properties of
various data structures and able to
identify the strengths and weaknesses
of different data structures.
• To analyze and compare the efficiency
of algorithms and learn to design
2
efficient algorithms for solving
Course Outcomes
CO Course Outcome
Number

CO1 Understand the concepts of object-oriented programming including


programming process and compilation process.
CO2 Apply different techniques to decompose a problem and
programmed a solution with various concepts of object-oriented
programming language.
CO3 Analyse and explain the behaviour of linear data structure
operations using the programming addressed in the course.
CO4 Implement and evaluate the programs using the syntax and
semantics of object-oriented programming.
CO5 Design the solution of real-world problems in order to determine
that the program performs as expected.

3
Scheme of Evaluation

Direct Evaluation Weightage of actual Final Weightage in Mapping with SIs Remarks
Sl No. Frequency of Task BT Levels CO Mapping Mapping with PIs
Instruments conduct Internal Assessment (ABET) (Graded/Non-Graded)

SO1 1a,1b,1c
10 marks for each
1 Assignment One per unit 10 Hard CO4,CO5 Graded
assignment

SO6
2 Exam 20 marks for one MST 2 per semester 20 Medium CO1,CO2,CO3,CO4 6a,6b Graded

3 Case Study 8 marks 1 per unit 8 Easy CO2 SO1, SO6 1c,6b Graded
NA NA NA NA
One per lecture
4 Homework NA topic (of 2 NA Non-Graded
questions)

NA NA NA NA
5 Discussion Forum NA One per unit NA Non-Graded

NA NA NA NA
6 Presentation NA NA NA Non-Graded

7 Attendance NA NA 2 NA NA NA NA Graded

Remarks
Direct Evaluation Final Weightage in Mapping with SIs
S No. Weightage of actual conduct Frequency of Task BT Levels CO Mapping Mapping with PIs (Graded/Non-
Instruments Internal Assessment (ABET)
Graded)
Unit wise Practical 1a, 1b, 1c, 6a, 6b SO1, SO6
1 15 marks 3 45 Medium 1,2,3,4,5 Graded
Evaluation
1a, 1b, 1c, 6a, 6b
2 Exam 15 marks for one MST 1 per semester 15 Medium 1,2,3 SO1, SO6 Graded
3 Attendance NA NA 2 NA NA NA NA Graded

4
What
. A class is user defined
data type defined in C+
+ using Why
keyword class followed by A class in C++ is the building
the name of class. The block, that leads to Object-
body of class is defined Oriented programming. It is a
inside the curly brackets user-defined data type, which
and terminated by a holds its own data members and
semicolon at the end. member functions, which can be
accessed and used by creating an
instance of that class.
CONTENTS

• Specifying a class
• Creating Objects
• Accessing the class members

6
Class

• A class is user defined data type which consists of two sections, a private and a
protected section that holds data and a public section that holds the interface
operations.
• A class definition is a process of naming a class and data variables, and methods
or interface operations of the class.
• Once a class has been defined, we can create any number of objects belonging to
that class.
• A class is collection of objects of similar type.

Example-- If fruit has been defined as a class, then the statement


fruit mango;
will create an object mango belonging to the class fruit. 7
Specifying A Class

Class specification has two parts:


• Class declaration
• Class function definitions
• Class declaration describes type and scope of its members
• Class function definition describes how class functions are implemented.
Example:
class class_name
{ private: variable declarations;
public: function declaration;
};

8
Objects

• Oops uses object as fundamental Building Block Definitions.


• Objects are the basic run time entities in object oriented System.
• Every object is associated with Data and Functions which define
meaningful operations on an object.
• Object is a real world existing entity.
• Object is an instance of a particular class.

9
Creating Objects

• Objects are created from classes. Class objects are declared in a similar way as
variables are declared. The class name must start, followed by the object name.
For example,
ABC ob1,ob2; //object declaration will create two objects ob1 and
ob2 of ABC class type.
• Memory space is allocated separately to each object for their data members.
• Member variables store different values for different objects of a class.

10
Accessing Class Members

• Accessing a data member depends on the access control of that data


member. If its public, then the data member can be easily accessed
using the direct member access (.) operator with the object of that
class.
• If, the data member is defined as private or protected, then we
cannot access the data variables directly. Then we will have to create
special public member functions to access, use or initialize the private
and protected data members. These member functions are also
called Accessors and Mutator methods or getter and setter functions.

11
Accessing Class Members

class person { //class declaration


public: //access specifier
string name; //variable declaration
int number;
};
main() { //main function
person obj; //object creation for class
cout<<“Enter name:”; //get input values for object variables
cin>>obj.name;
cout<<“Enter number:”;
cin>>obj.number;
cout<<obj.name<<“:”<<obj.number<<endl;
12
Accessing Public Class Members(Example)

Following is an example to show you how to initialize and use the public data members
using the dot (.) operator and the respective object of class.
class Student
{
public:
int rollno;
string name;
};
int main()
{
13
Accessing Public Class Members

Student A;
Student B;
// setting values for A object
A.rollno=2021;
A.name="Karan";
// setting values for B object
B.rollno=20212121;
B.name="Arjun";
cout <<"Name and Roll no of A is: "<< A.name << "-" << A.rollno;
cout <<"Name and Roll no of B is: "<< B.name << "-" << B.rollno;
}

14
OUTPUT:

Name and Roll no of A is: Karan-2021


Name and Roll no of B is: Arjun-20212121

15
Summary

In this lecture we have We have discussed about how


discussed about Class. to specify a class.

Discussed about how to create Discussed about Accessing


Objects. Class members.

16
Frequently Asked question

Q1What is a class?
A class is user defined data type which consists of two sections, a private and a
protected section that holds data and a public section that holds the interface
operations. A class definition is a process of naming a class and data variables, and
methods or interface operations of the class. A class is defined in C++ using
keyword class followed by the name of class. The body of class is defined inside the curly
brackets and terminated by a semicolon at the end.

Q2 What is an object?
An Object is an instance of a Class. When a class is defined, no memory is allocated but
when it is instantiated (i.e. an object is created) memory is allocated. For example: in real
life, a car is an object.
17
Q3 How to create an object?
Objects are created from classes. Class objects are declared in a
similar way as variables are declared. The class name must start,
followed by the object name.
class name object name;

18
Assessment Questions:
1. Where does the object is created?

A. Class
B. Constructor
C. Destructors
D. Attributes

2.A member function can always access the data in __________ , (in C++).
(A) the class of which it is member
(B) the object of which it is a member
(C) the public part of its class
(D) the private part of its class

19
Discussion forum.
How to create Class and Objects CPP?
How to access class members?

https://youtu.be/6Q0Cff29YwU
https://youtu.be/n9Ej2J0m4a0

20
REFERENCES
Reference Books:

[1] Programming in C++ by Reema Thareja.


[2] Programming in ANSI C++ by E. Balaguruswamy, Tata McGraw Hill.
[3] Programming with C++ (Schaum's Outline Series) by Byron
Gottfried Jitender Chhabra, Tata McGraw Hill.

Websites:
• https://www.tutorialspoint.com/cplusplus/cpp_classes_objects.htm
• https://www.w3schools.com/cpp/cpp_classes.asp
YouTube Links:
• https://youtu.be/6Q0Cff29YwU
• https://youtu.be/n9Ej2J0m4a0

21
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy