1 Crore+ students have signed up on EduRev. Have you? Download the App |
Output of following program
#include<iostream>
using namespace std;
class Base
{
public:
virtual void show() { cout<<" In Base n"; }
};
class Derived: public Base
{
public:
void show() { cout<<"In Derived n"; }
};
int main(void)
{
Base *bp, b;
Derived d;
bp = &d;
bp->show();
bp = &b;
bp->show();
return 0;
}
How many max number of arguments can present in function in c99 compiler?
What is the output of the program?
#include<iostream>
using namespace std;
class Base
{
public:
virtual void show() = 0;
};
int main(void)
{
Base b;
Base *bp;
return 0;
}
What is the output of this program?
#include < iostream >
using namespace std;
void mani()
void mani()
{
cout << "hai";
}
int main()
{
main();
return 0;
}
What is the output of the program?
#include<iostream>
using namespace std;
class Base
{
public:
virtual void show() = 0;
};
class Derived: public Base
{
public:
void show() { cout<<"In Derived n"; }
};
int main(void)
{
Derived d;
Base &br = d;
br.show();
return 0;
}
What is the scope of the variable declared in the user definied function?
Can a destructor be virtual? Will the following program compile?
#include <iostream>
using namespace std;
class Base {
public:
virtual ~Base() {}
};
int main() {
return 0;
}
Can static functions be virtual? Will the following program compile?
#include<iostream>
using namespace std;
class Test
{
public:
virtual static void fun() { }
};
What is the output of the program?
#include <iostream>
using namespace std;
class A
{
public:
virtual void fun() { cout << "A::fun() "; }
};
class B: public A
{
public:
void fun() { cout << "B::fun() "; }
};
class C: public B
{
public:
void fun() { cout << "C::fun() "; }
};
int main()
{
B *bp = new C;
bp->fun();
return 0;
}
Predict the output of following C++ program
#include<iostream>
using namespace std;
class Base
{
public:
virtual void show() { cout<<" In Base n"; }
};
class Derived: public Base
{
public:
void show() { cout<<"In Derived n"; }
};
int main(void)
{
Base *bp = new Derived;
bp->Base::show(); // Note the use of scope resolution here
return 0;
}
73 videos|7 docs|23 tests
|