13420.Placement Corner Question Set 2
-
Upload
milan-mehta -
Category
Documents
-
view
212 -
download
0
description
Transcript of 13420.Placement Corner Question Set 2
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 1/6
Placement Corner Question Set 2Predict the output#include<iostream>using namespace std;class One{ public: int x;
;int main!"{ One p $ ne% One!";
!p"&x $ '(; cout<< !p"&x << ) ) << p*>x << ) ) ;
p*>x $ 2(; cout<< !p"&x << ) ) << p*>x ;
return (;
Question 2
#include<iostream>using namespace std;
class +%o{ static int x;
public: static ,oid Set-ata!int xx" { x $ xx;
,oid -ispla.!"{
cout<< x ; ;int +%o::x $ (;int main!"{
+%o::Set-ata!//"; +%o::-ispla.!"; return (;
#include<iostream>using namespace std;class 0our{
int x1 .;public:
0our!int xx" {
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 2/6
x $ xx; ,oid -ispla.!" { cout<< **x << ) ); ;int main!"
{ 0our ob3!45"; ob3&-ispla.!"; int p $ !int"6ob3; p $ 2/; ob3&-ispla.!"; return (;
#include<iostream>
using namespace std;class 0i,e{ static int x;
public: ,oid Set-ata!int x" { this*>x $ x;
static ,oid -ispla.!"{
cout<< x ;
;int 0i,e::x $ (;int main!"{
0i,e ob3; ob3&Set-ata!22"; 0i,e::-ispla.!"; return (;
#include<iostream>
#include<cstring>using namespace std;
class Six{ int ,al;
public: ,oid Set7alue!char str'1 char str2" { ,al $ strcspn!str'1 str2";
,oid Sho%7alue!" {
cout<< ,al;
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 3/6
;int main!"{ Six ob38ix; ob38ix&Set7alue!!char")9bc)1 !char")c9)";
ob38ix&Sho%7alue!";return (;
#include<iostream>#include<cstring>using namespace std;class ight{ public: ,oid et-ata!char s1 int x1 int . "
{
int i $ (; =or !i $ x*'; .>(; i" { cout<< si?; .**;
;int main!"
{ ight ob3; ob3&et-ata!!char")@elcomeA)1 21 /";
return (;
#include<iostream>using namespace std;class Bine
{ int x1 .1 ;
public: Bine!int x1 int .1 int " { this*>x $ x;
this*>. $ .; this*> $ ;
,oid Sho%!" { cout<< )) << x << ) ) << . << ) ) << ;
;int main!"
{ Bine ob3!'1 21 /";
ob3&Sho%!"; return (;
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 4/6
#include<iostream>using namespace std;class +en{
int x;=loat .;public:
,oid 0unction!" { x $ 4;
. $ 2&5(;delete this;
,oid -ispla.!" {
cout<< x << ) ) << .;
;int main!"{ +en p$ ne% +en!"; p*>0unction!";
p*>0unction!";p*>-ispla.!";return (;
#include<iostream>#include<cstdlib>using namespace std;class t%ele,e{ static int x;
public:
t%ele,e!" { i=!x $$ '" brea;
else
x;
,oid -ispla.!" { cout<< x << ) ); ;int t%ele,e::x $ (;int main!"{
t%ele,e ob3';ob3'&-ispla.!";
t%ele,e ob32;ob32&-ispla.!";
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 5/6
return (;
#include<iostream>using namespace std;
class mpt. {; int main!"
{ cout <<sieo=!mpt."; return (;
#include<iostream>using namespace std;
class +est {
int x;
;int main!"{ +est t; cout << t&x; return (;
#include<iostream>using namespace std;
class +est{ static int x; int ptr; int .;;
int main!"{ +est t; cout << sieo=!t" << ) ); cout << sieo=!+est ";
#include <iostream>
using namespace std;class +est{public: int i; ,oid get!";;,oid +est::get!"
{ cout << )nter the ,alue o= i: );
cin >> i;
7/21/2019 13420.Placement Corner Question Set 2
http://slidepdf.com/reader/full/13420placement-corner-question-set-2 6/6
+est t; DD lobal ob3ectint main!"{ +est t; DD local ob3ect t&get!"; cout << ),alue o= i in local t: )<<t&i<<EFnE; ::t&get!";
cout << ),alue o= i in global t: )<<::t&i<<EFnE;
return (;
#include<iostream>using namespace std;class Point { Point!" { cout << )Constructor called); ;
int main!"{ Point t'; return (;
#include<iostream>using namespace std;
class Point {public:
Point!" { cout << )Constructor called)<<endl; ; int main!"{
Point t'1 t2; return (;