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; #define FUN(arg) if(arg) cout<<"Test"; int main() { int i=1; FUN(i<3); return 0; }A . It prints: 0 B.It prints: T C.It prints: T0 D.It prints: TestView AnswerAnswer: D
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...
person?
What is the output of the program? #include <iostream> #include <string> using namespace std; struct Person { int age; }; class First { Person *person; public: First() {person = new Person; person?>age = 20; } void Print(){ cout << person?>age; } }; int main() { First t[2]; for (int i=0;...
What will the variable "y" be in class B?
What will the variable "y" be in class B? class A { int x; protected: int y; public: int age; }; class B : private A { string name; public: void Print() { cout << name << age; } };A . public B.private C.protected D.None of theseView AnswerAnswer: B
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 = 1; if (--i==1) { cout << i; } else { cout << i-1; } return 0; }A . It prints: 0 B.It prints: 1 C.It prints: -1 D.It...
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; const int size = 3; class A { public: string name; A() { name = "Bob";} A(string s) { name = s;} A(A &a) { name = a.name;} }; class B...
A(string s) { this?
What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { public: string s; A(string s) { this?>s = s; } }; class B { public: string s; B (A a) { this?>s = a.s; } void print() {...
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 x=5; static int y; int i=0; void static myFunction() { y=x++ + ++i; } int main (int argc, const char * argv[]) { x++; myFunction(); cout<<y<<" "<<x<< " " << i; }A...
s.resize (s.size() ?
What happens when you attempt to compile and run the following code? #include <iostream> #include <sstream> #include <string> using namespace std; int main(void) { string s; s = "Test"; s.resize (s.size() ? 1); cout<<s<<" "<<s.size(); return 0; }A . It prints: Test 4 B.It prints: Test 3 C.Compilation error D.It...
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:...