+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Tags:
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)its today my papar ....
Q.5
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.
Private inheritance
Public inheritance
Protected inheritance
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
Cs304(23-8-2016)
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
public inheritance
private inheritance
protected inheritance.
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
asslam o alikum! kindly tell me the answer of the following question
2:write a program where template A is the friend of template B
myra paper suba 8 bjy hai plz koe bata dy
1.#include <iostream>
13. class MyClass<int*>{
15. MyClass(){
17. }
19.
20. int main(int argc, char *argv[])
21. {
26. }
++, --, =, /
class Shape {
…
protected:
char _type;
public:
Shape() { } void draw(){ cout “Shape\n”; } int calcArea() { return 0; } char getType() { return _type; } };
class Line : public Shape {
public:
Line(Point p1, Point p2) {
}
void draw(){ cout “Line\n”; } };
class Circle : public Shape {
public:
Circle(Point center, double radius) {
}
void draw(){ cout “Circle\n”; } int calcArea() { … } };
class Triangle : public Shape {
public:
Triangle(Line l1, Line l2, double angle) {
}
void draw(){ cout “Triangle\n”; } int calcArea() { … }
};
int main() {
Shape* _shape[ 10 ];
Point p1(0, 0), p2(10, 10); shape[1] = new Line(p1, p2); shape[2] = new Circle(p1, 15);
void drawShapes( shape, 10 ); return 0;
}
/*Function drawShapes()*/
void drawShapes(Shape* _shape[], int size) {
for (int i = 0; i < size; i++) { _shape[i]->draw();
}
}
After compiling this code we will see the following output,
Shape
Shape
Shape
Shape
…
If we want to display the following output
Line
Circle
Triangle
Circle
…
How can we achieve this?
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
Private Inheritance
Public Inheritance
Protected Inheritance
Answer:
We can achieve specialization by using Private and Protected inheritance.
Q. Describe three properties necessary for a container to implement generic algorithms.
Answer:
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.
Answer:
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++
Answer:
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.
Answer:
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.
Answer:
Function declaration:
template<class T>
T maximum(T first, T second);
//Precondition: The operator < is defined for the type T.
//Returns the maximum of first and second.
Definition:
template<class T>
T maximum(T first, T second)
{
if (first < second)
return second;
else
return first;
}
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
Please point out if the answers are wrong.
cs101-cs201-cs301-cs304-cs-601-cs504 past papers
http://tecoknowledge.blogspot.com/2018/02/cs101-cs201-cs301-cs304-c...
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post