2006 Delhi:
2.c. Define a class named ADMISSION in C++ with the following descriptions:
Private Members:
AD_NO | integer(Ranges 10 – 2000) |
NAME | Array of characters(String) |
CLASS | Character |
FEES | Float |
Public Members: Function Read_Data( ) to read an object of ADMISSION type. Function Display( ) to display the details of an object. Function Draw-Nos.( ) to choose 2 students randomly. And display the details. Use random function to generate admission nos. to match with AD_NO.
Ans:
class ADMISSION
{
int AD_NO;
char NAME[31];
char CLASS;
float FEES;
public: void Read_Data( )
{
cout<<"\nEnter the Admission Number: ";
cin>>AD_NO;
cout<<"\nEnter the Student Name: ";
gets(NAME);
cout<<"\nEnter the Class: ";
cin>>CLASS; cout<<"\nEnter the Fees: ";
cin>>FEES; } void Display()
{
cout<<"\nThe Admission Number of the student: "<<AD_NO;
cout<<"\nThe name of the Student: "<<NAME;
cout<<"\nThe Class of the Student: "<<CLASS;
cout<<"\nThe Fees of the Student: "<<FEES;
} void Draw_Nos();
};
void ADMISSION::Draw_Nos( )
{
//Dear Students, a test for you. Complete this member function.
}
2006 Outside Delhi:
1.b. Illustrate the use of Inline function in C++ with the help of an example. 2
Ans: INLINE FUNCTIONS: The inline functions are a C++ enhancement designed to speed up programs. The coding of normal functions and inline functions is similar except that inline functions definitions start with the keyword inline.