Object Oriented Programming: Chapter 2: Classes and Objects

Classes

C++ Programming | Object Oriented Programming

Each class is a collection of data and functions that manipulate the data.

Chapter‒2

Classes and Objects

 

Classes

• Each class is a collection of data and functions that manipulate the data.

• Placing the data and functions together into a single entity is the central idea in object oriented programming.

• The nouns in the system specification help the C++ programmer to determine the set of classes. The objects for these classes are created. These objects work together to implement the system.

• Classes in C++ is the natural evolution of C notion of struct.

For example:

class rectangle

{

       private:

       int len,br;

       public:

       void get_data();

       void area();

       void print_data();

};

• Rules for declaring class name 

1. The class name must begin with the letters, it may be followed by letters, digits or underscore.

2. The name of the class must not be same as keyword or reserved word.

3. The class name must not contain any special character such as ~,!,@,#,$, %,^,&,*,(,), {,}, [,],+,‒,,/,\

Difference between Structure and Class


Structure

1.By default the members of structure are public.

2.The structure can not be inherited.

3.The structures do not require constructors.

4. A structure contains only data members.

Class

1. By default the members of class are private.

2. The class can be inherited.

3. The classes require constructors for initializing the objects.

4. A class contains the data as well as the function members.

 

Object Oriented Programming: Chapter 2: Classes and Objects : Tag: Oops, Computer Programming : C++ Programming | Object Oriented Programming - Classes


Object Oriented Programming: Chapter 2: Classes and Objects



Under Subject


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs) - Laboratory

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation