 CPP All : Defining Classes Concept Notes and Resources #### Why do we need classes #5174

Exam Paper Problems #### Writing Class Definition #5261

( As In Exam - CBSE12A-2018 )

Write the definition of a class CONTAINER in C++ with the following descripti

Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Type // int (1 for Cone,2 for Cylinder)
– Volume // float
– CalVolume() // Member function to calculate volume as per the Type

Type Formula to calculate Volume

Public Members
– GetValues() // A function to allow user to enter value of Radius, Height and Type. Also, call
function CalVolume() from it.
– ShowAll() // A function to display Radius, Height, Type and Volume of Container

#### Defining Class Based on Data Members and Functions Given #5634

( As In Exam - CBSE12A-2016 )

Write the definition of a class CITY in C++ with following description:

<

Write the definition of a class CITY in C++ with following description:

Private Members

Ccode         //Data member for City Code (an integer)
CName      //Data member for City Name (a string)
Pop              //Data member for Population (a long int)
KM              //Data member for Area Coverage (a float)
Density      //Data member for Population Density (a float)
DenCal()   //A member function to calculate Density as Pop/KM

Public Members
Record()   //A function to allow user to enter values of Acode,Name,Pop,KM and call DenCal() function
View() //A function to display all the data members. Also display a message ”Highly Populated City”
if the Density is more than 10000

#### 02C #5759

( As In Exam - CBSE12A-2017 )

Write the definition of a class BOX in C++ with following description:

Write the definition of a class BOX in C++ with following description:
Private Members
– BoxNumber // data member of integer type
– Side // data member of float type
– Area // data member of float type
– ExecArea() // Member function to calculate and assign
// Area as Side * Side
Public Members
– GetBox() // A function to allow user to enter values of
// BoxNumber and Side. Also, this
// function should call ExecArea() to calculate
// Area
– ShowBox() // A function to display BoxNumber, Side
// and Area

#### 02C #5863

( As In Exam - CBSE12D-2015 )

Write the definition of a class PlC in C++ with following description:

Write the definition of a class PlC in C++ with following description:
Private Members

```Pno       //Data member for Picture Number (an integer)
Category  //Data member for Picture Category (a string)
Location  //Data member for Exhibition Location (a string)
FixLocation  //A member function to assign
//Exhibition Location as per category
//as shown in the following table```
 Category Location Classic Amina Modern Jim Plaq Antique Ustad Khan
```Public Members
Enter()     //A function to allow user to enter values
//Pno, category and call FixLocation() function
SeeAll()    //A function to display all the data members```

#### 02C-2015 #5947

( As In Exam - CBSE12A-2015 )

Write the definition of a class Photo in C++ with following description:

Write the definition of a class Photo in C++ with following description:

```Private Members
Pno        //Data member for Photo Number
(an integer)
Category   //Data member for Photo Category
(a string)
Exhibit    //Data member for Exhibition Gallery
(a string)
FixExhibit //A member function to assign
//Exhibition Gallery as per Category
//as shown in the following table
Category  Exhibit
Antique   Zaveri
Modern    Johnsen
Classic   Terenida

Public Members
Register()  //A function to allow user to enter
//values
//Pno,Category and call FixExhibit()
//function
ViewAll()   //A function to display all the data
//members```

#### 02C #6027

( As In Exam - CBSE12D-2017 )

```Write the definition of a class RING in C++ with following description:
Pr

```
```Write the definition of a class RING in C++ with following description:
Private Members
- RingNumber   // data member of integer type
- Radius       // data member of float type
- Area         // data member of float type
- CalcArea()   // Member function to calculate and assign
Public Members
- GetArea()    // A function to allow user to enter values of
// RingNumber and Radius. Also, this
// function should call CalcArea() to calculate
// Area
- ShowArea()   // A function to display RingNumber, Radius
// and Area```

#### 02C-2016 #6160

( As In Exam - CBSE12D-2016 )

```Write the definition of a class METROPOLIS in C++ with following descriptio

```
```Write the definition of a class METROPOLIS in C++ with following description:
Private Members
-Mcode    //Data member for Code (an integer)
-MName    //Data member for Name (a string)
-MPop     //Data member for Population (a long int)
-Area     //Data member for Area Coverage (a float)
-PopDens  //Data member for Population Density (a float)
-CalDen() //A member function to calculate
//Density as PopDens/Area
Public Members
-Enter()  //A function to allow user to enter values of
//Mcode,MName,MPop,Area and call CalDen()
//function
-ViewALL()//A function to display all the data members
//also display a message "Highly Populated Area"
//if the Density is more than 12000```
Solved Problems #### Code error in class #5179

Find error (if any) in the following class definition.

```Class PLAY
{

```

Find error (if any) in the following class definition.

```Class PLAY
{
int number_of_actors=5;
void set_actor_count()
{
number_of_actors=10;
}
};```

Concept Notes:1  Exam Paper Problems:7  Solved Problems:1
×