Can’t find an answer?

Can’t find an answer?

Ask us to get the answer

Define a class to represent a book in a library. Include the following members: Data Members

Book Number, Book Name, Author, Publisher, Price, No. of copies issued, No. of copies Member Functions

(i) To assign initial values

(ii) To issue a book after checking for its availability

(iii) To return a book

(iv) To display book information.

When will you make a function inline and why?

Identify the error(s) in the following code fragment:

int x = 5;

int y = 3;

class Outer {

public:

int x;

int a;

static int s;

class Inner {

public:

void f(int i)

{

x = i;

s = i;

y = i;

a = i;

}

};

// Inner defination over

Inner I1; //Inner object

void g(it i)

{

x = i;

y = i;

a = i;

s = i;

}

 }; 

//outer definition over

Outer Ob1; // outer object int main()

{

Ob1.I1.f(3);//statement1

Ob1.g(8); //statement2

return 0;

}

What will be the values of ::x, ::y, Outer::x, Outer::a, Outer::s, Inner::a after statement 1 and statement 2 of above code?

Rewrite the following C++ code after removing the syntax error(s) (if any). Underline each correction.

include<iostream.h>

class FLIGHT{

 long FlightCode;

 char Description[25];

 public:

void AddInfo ()

{

cin>>FlightCode; gets(Description);

}

void ShowInfo()

{

cout<<FlightCode<<“:” <<Description<<end1;

}

};

void main() {

FLIGHT F; 

AddInfo.F();

 ShowInfo.F();

}

Identify the error(s) in the following code fragment:

class X {

int a b;

void count(void)

{

a++;

}

public:

int x;

void init(int,int,int);

void print(void);

};

void X::init(int i,int j,int k)  {

a = i;

b = j;

x = k;

}

void X::print(void)

{

count();

cout<<“a=”<<a;<<“b=”

 <<b<<“x=”<<x<<“\”;

}

void func(void);

X Ob1;

int main() {

X Ob2;

Ob1.init(0,1,2);

Ob2.init(2,3,4);

Ob1.print();

Ob2.print();

Ob1.count();

Ob2.count();

}

void func(void)

X Ob3;

Ob1.init(4,5,6);

Ob2.init(7,8,9);

Ob3.init(9,10,11);

Ob3.a = Ob3.b = Ob3.x;

Ob1.count();

Ob2.count();

Ob3.count();

Ob1.print();

Ob2.print();

Ob3.print();

}

Rewrite the following program after removing the syntactical error(s) (if any). Underline each correction.

#include[iostream.h]

#include[stdio.h]

class Employee {

 int EmpId = 901;

 char EName[20];

 public:

Employee()  {}

void Joining()

{

cin>>EmpId; gets(EName);

}

void List ()

{

cout<<EmpId<<“:”

 <<EName<<end1;

}

}

void main() {

Employee E;

Joining.E ();

E.List () ;

}

Define a class Teacher with the following specification: private members:

name20 characters
subject10 characters
Basic,DA,HRAfloat
salaryfloat

Calculate() function computes the salary and returns it. Salary is sum of Basic, DA and HRA

public members:

Readdata() function accepts the data values and invoke the calculate function Displaydata() function prints the data on the screen.

Which is the most significant feature that arises by using template classes?

(a) Code readability

(b) Ease in coding

(c) Code reusability

(d) Modularity in code

A template class defines the form of a class _____________________ it will operate.

(a) With full specification of the data on which

(b) With full specification of the functions on which

(c) Without full specification of the data on which

(d) Without full specification of the functions on which

What is the syntax to use explicit class specialization?

(a) template class myClass<>{  }

(b) template class myClass{  }

(c) template <> class myClass<>{  }

(d) template <> class myClass{  }

Viewing 15 topics - 16 through 30 (of 54 total)

1 2 3 4
  • You must be logged in to create new topics.