What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> #include <exception> using namespace std; class myClass : public exception { virtual const char* what() const throw() { return "My exception."; } } obj; int main () { try { throw obj; } catch (exception& e)...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main(){ int i, j; for(i = 0, j = 1; j < 2, i < 4; i++, j++); cout << i << " " << j; return 0; }A . It prints:...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: void print() { cout << "A "; } }; class B { public : void print() { cout << "B "; } }; int main() { B sc[2]; A...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int fun(int x); int main() { cout << fun(0); return 0; } int fun(int x) { if(x > 0) return fun(x-1); else return 100; }A . It prints: 0B . It prints: 10C...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { int x; protected: int y; public: int z; A() { x=1; y=2; z=3; } }; class B: public A { string z; public: void set() { y =...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int fun(int x) { return x<<2; } int main(){ int i; i = fun(1) / 2; cout << i; return 0; }A . It prints: 0B . It prints: 1C . It prints:...
What will happen if we use the operator “new” and the memory cannot be allocated?
Given: #include <iostream> #include <exception> using namespace std; int main () { try { int * myarray= new int[1000]; } catch (bad_alloc&) { cout << "Error allocating memory"; } catch (exception& e) { cout << "Standard exception"; } catch (...) { cout << "Unknown exception"; } return 0; } What...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class complex{ double re; double im; public: complex() : re(0),im(0) {} complex(double x) { re=x,im=x;}; complex(double x,double y) { re=x,im=y;} void print() { cout << re << " " << im;} }; int...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> #include <cstdarg> using namespace std; int mult(int f, int s, int t); int main() { cout << mult(1,2,3); return 0; } int mult(int f, int s, int t) { int mult_res; mult_res = f*s*t; return mult_res;...
What happens when you attempt to compile and run the following code?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class First { public: void Print(){ cout<<"from First";} }; class Second { public: void Print(){ cout<< "from Second";} }; int main() { First FirstObject; FirstObject.Print(); Second SecondObject; SecondObject.Print(); }A . It prints: from...