Virtual University of Pakistan Study forum !
Mostly MCQs from moaaz file (304)
1:Differentiate between unary and binary operators
2:write a program where template A is the friend of template B
3Smiling Showing Teethescribe Graceful error handling with C++ example
4:write a program according to given scenerio
5:find the error of given program mention them with line number and correct them
6:Complete the code of given template program
7:According to the given program describe which is the direct and in direct base class for the given class
8:According to the given program complete the table of inheritance
9:if vehicle class and van class are with public inheritance then the public or private members of the derived class can access the member of the base class( kuch aesa hi the exactly bhool gai :-P )
Baqi bi code hi likhny thy
Suppose we have a person class with an attribute age and we want another class veter with with same attribute but with retriction that age can only be greater than 18 year . both class have setage function that set their repective attribute age with passed value is fulling the class condition value is greater then the 18 is case of vector class .
You have to give the code of implementation in the term person and vector in c++.
Q. How we use the concept of overloading to convert a type according to our own requirement. Give example
Q. Using this how achieve specialization.
Q. What is graceful termination method error handling give example c++ code.
Q. Write the c++ code to declare the a template class ‘A’ as friend of the other template class ‘B’.
Q. While over loading the stream insertion and extraction operator a program can not declare ostream reference as constant why?
Q. Sort following data in order for .
Complete specialization ,partial specialization generic template function order
1. code was given and asked to write output.
2. Write a template function that returns the average of all elements of an array. The argument to the function should be Array name and size of an array.
3. Define public and private inheritance with examples.
4. Code was given and asked to write logical errors.
5. We can achieve specialization from which of the following
6. Can we initialize a class if a constructor and destructor are declared as private. Justify.
7. What is meant by Stack Unwinding
8. Suppose person class is an abstract class which has some specific features. Briefly describe important features of abstract class.
9. What are non type parameters for template.
10. What is anonymous base class object. Give an example.
11. If we declare a function as friend of template class then will it be a friend for particular data type or for all data type of that class. Justify
Today Paper Long Questions CS304:
Tried to solve them also please mark if anything wrong.
Q. Using which of the following we can achieve specialization
We can achieve specialization by using Private and Protected inheritance.
Q. Describe three properties necessary for a container to implement generic algorithms.
We claimed that this algorithm is generic, because it works for any aggregate object (container) that defines following three operations.
a. Increment operator (++)
b. Dereferencing operator (*)
c. Inequality operator (!=)
Q. List down any three cases in which copy constructors are called.
1. When instantiating one object and initializing it with values from another object.
2. When passing an object by value.
3. When an object is returned from a function by value.
Q. Name the technique which is used to implement Generic Algorithms in C++
Generic algorithms in C++ are written using C++ templates
Q. Binding is the process that connects the function call to function implementation you are required to name the type of binding in which this process is done at run time instead of compile time.
The simplest form of run-time binding is polymorphism. In context of C++ polymorphism is achieved through virtual functions.
Q. While Overloading stream insertion and extraction operators a programmer cannot declare ostream and istream referenced as a constant why?
Answer: istream cannot be constant and istream buffer will change as we will get data from it and assign it to complex reference similarly Complex object cannot be constant for stream extraction operator as well because we will add data to it and hence its state will change.
Q. Write a function template named maximum. The function takes two values of the same type as its arguments and returns the larger of the two arguments (or either value if they are equal) give the function prototype and definition for the template.
T maximum(T first, T second);
//Precondition: The operator < is defined for the type T.
//Returns the maximum of first and second.
T maximum(T first, T second)
if (first < second)
A template is not a class or a function.
A template is a “pattern” that the compiler uses to generate a family of classes or functions
Total number of Questions 57:
45 MCQs 98% from Moaaz file.
1. Write two types of cursor or iterator
2. Write a program in which Class A is declear as friend with class B.
3. Write Private and public inheritence with example.
4. Write types of binding error, which shows errors run time error instead of compile time.
5. Write catch handlor.
6. Two Questions: correction in given progrm (remove error from program.
7. 3 Questions: show output of the given program.
8. Modify program. (the o/p of the program was
Modify to give o/p
Best of luck
my today's cs304 paper
sort of search compiler
70% papers from moaz file
cs304 ka paper tha generic programming ka
mujhe 3 questions ae the programme to correct krny waly
2. vector class m friend funtion
3. iteration k kisi portion sy aya tha
try block k code ka output aya tha
inheritence k m grandparent class accessing k related ques the
what is virtual function how we can make function pure virtual or virtual
m to yehe kaho ga k iteration wala lazmy parh kr jaye ga
STL m sy ques aye the