Consider following code and state the order of execution constructors and order of execution of destructors.
class C: public A, virtual public B
{ public:
C( ):A( ),B( )
{
cout<<”c class constructor”;
}
};
Include the definition for the function ‘max_age’, in the program given below. The function compares the data member age of the objects P1 and P2 and returns the object having higher value for age.
class person
{ int age;
public:
person(int a){age=a;}
};
int main()
{ person P1(1.5);
person P2(2.5);
person P3=P1.max_age(P2);
}
Find the errors in the following program and correct them.
[Assume the necessary header files and namespaces included
class test
{ static int x;
int y;
public:
test( ){x=0;y=0;}
static void display()
{ cout<<x<<”\t”<<y<<endl; }
void output()
{cout<<x<<”\t”<<y<<endl;}
};
int main()
{ test T1;
T1.display();
test::output();
return 0;
}
Declares an array of 20 components; initializes list[0] to 4 and list[1] to 7; all other components are initialized to 0.
An array is type of data structure that stores the elements in contiguous block of memory, create an array with name "list" and size of an array is N. your task is to print the array elements in an reverse order.
list-[1,2,3,4,5)
output 5,4,3,2,1
Note: use function concept to process the array elements and print it in the reverse order.
Reverse array has the following parameter
int list[n]
return int
Write a Menu driven Program which include these operations like Creating an array, insertion, deletion and fetching all the elements from an array?
create a class student which store name roll no. age of the student. Derive a class test from student class which store marks of 5 subjects input and display the details of student