CS304 Current pprs ( 22 feb to 6 march ) here ... !!!
Describe cache handler. (2)
Can an object have more then one aspects? Describe briefly (3)
There are some errors in the code given below, you have to Indicate the line no. with error/s Give the reason for error/s Correct the error/s. (5)
1. #include <iostream>
2. #include <stdlib.h>
3. using namespace std;
4. template <typename T>
5. class MyClass{
6. public:
7. MyClass(){
8. cout"This is class1"endl;
9. }
10. };
11.
12. template <typename T>
13. class MyClass<int*>{
14. public:
15. MyClass(){
16. cout"This is class2"endl;
17. }
18. };
19.
20. int main(int argc, char *argv[])
21. {
22. MyClass<int> c1;
23. MyClass<int*> c2;
24. system("PAUSE");
25. return 0;
26. }
What will be the output after executing the following code? (5)
class c1
{
public: virtual void function()
{
cout”I am in c1”endl;
}
};
class c2: public c1
{ public: void function()
{ cout”I am in c2”endl;
}
};
class c3: public c1
{
public: void function()
{
cout”I am in c3”endl;
}
};
int main()
{
c1 * test1 = new c2();
c1 * test2 = new c3();
test1->function();
test2->function();
system(“PAUSE”); return 0;
}
0 comments
Post a Comment