July 9, 2021 in C and CPP
Write short notes on any three:
9. Write short notes on any three:
a) Stream classes
b) Friend function
c) Exception handling
d) Multiple inheritance
July 9, 2021 in C and CPP
9. Write short notes on any three:
a) Stream classes
b) Friend function
c) Exception handling
d) Multiple inheritance
July 9, 2021 in C and CPP
b) Imagine a publishing company that markets both book and audiocassette version to its
works. Create a class publication that stores the title (a string) and price (type float) of a
publication. From this class derive two classes: book, which adds a page count (type
int); and tape, which adds a playing time in minutes (type float). Each of these three
classes should have a getdata( ) function to gets its data from the user at the keyboard,
and a putdata( ) function to display its data.
Write a main( ) program in C++ to test the book and tape classes by creating instances
of them, asking the user to fill in data with getdata( ), and than displaying the data with
putdata( ).
July 9, 2021 in C and CPP
a) Distinguish between overloaded functions and function templates.
July 9, 2021 in C and CPP
b) How is polymorphism achieved at run time? Explain with C++ coding.
July 9, 2021 in C and CPP
a) Explain the concept of operator overloading. Illustrate operator overloading concept to
concatenate strings.
July 9, 2021 in C and CPP
c) Implement a class sample with an overloaded + operator. Explain the following
statements:
s2=s1+10;
s2=10+s1;
where s1 and s2 are objects of class sample.
July 9, 2021 in C and CPP
b) Write a program in C++ that contains a class derived from base. The base class should
have a virtual function fun( ) and it should be overridden. Try to call fun( ) from the
constructor of the base class and display the result.
July 9, 2021 in C and CPP
a) Why member functions are not virtual by default?
July 9, 2021 in C and CPP
e) Why do we need to use constructors?
July 9, 2021 in C and CPP
d) Explain the advantages of pointers over references.