J
joehust
Caculate the value of i after each step
int x=2, y=x+30;
struct A{
static int x;
int y;
public:
operator int( ){ return x+y; }
A operator ++(int){ return A(x++, y++); }
A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }
int &h(int &x);
};
int &A::h(int &x)
{
for(int y=1; y!=1 || x<201; x+=11, y++)
if(x>200) { x-=21; y-=2;}
return x-=10;
}
int A::x=23;
void main( ){
A a(54, 3), b(65), c;
int i, &z=i, A::*p=&A::y;
i=b.x; //.................................¢Ù
z=a.x; //.................................¢Ú
i=c.*p; //.................................¢Û
i=a++; //.................................¢Ü
i=::x+c.y; //.................................¢Ý
i=a+b; //.................................¢Þ
b.h(i)=7; //.................................¢ß
}
and another one, write down the ouput of this program
#include <iostream.h>
struct A{A( ){ cout<<'A';}};
struct B{B( ){ cout<<'B';}};
struct C: A{C( ){ cout<<'C';}};
struct D: virtual B, C{D( ){ cout<<'D';}};
struct E: A{
C c;
E( ): c( ){ cout<<'E';}
};
struct F: virtual B, C, D, E{
F( ){ cout<<'F';}
};
void main( ){
A a; cout<<'\n';
B b; cout<<'\n';
C c; cout<<'\n';
D d; cout<<'\n';
E e; cout<<'\n';
F f; cout<<'\n';
}
int x=2, y=x+30;
struct A{
static int x;
int y;
public:
operator int( ){ return x+y; }
A operator ++(int){ return A(x++, y++); }
A(int x=::x+2, int y=::y+3){ A::x=x; A::y=y; }
int &h(int &x);
};
int &A::h(int &x)
{
for(int y=1; y!=1 || x<201; x+=11, y++)
if(x>200) { x-=21; y-=2;}
return x-=10;
}
int A::x=23;
void main( ){
A a(54, 3), b(65), c;
int i, &z=i, A::*p=&A::y;
i=b.x; //.................................¢Ù
z=a.x; //.................................¢Ú
i=c.*p; //.................................¢Û
i=a++; //.................................¢Ü
i=::x+c.y; //.................................¢Ý
i=a+b; //.................................¢Þ
b.h(i)=7; //.................................¢ß
}
and another one, write down the ouput of this program
#include <iostream.h>
struct A{A( ){ cout<<'A';}};
struct B{B( ){ cout<<'B';}};
struct C: A{C( ){ cout<<'C';}};
struct D: virtual B, C{D( ){ cout<<'D';}};
struct E: A{
C c;
E( ): c( ){ cout<<'E';}
};
struct F: virtual B, C, D, E{
F( ){ cout<<'F';}
};
void main( ){
A a; cout<<'\n';
B b; cout<<'\n';
C c; cout<<'\n';
D d; cout<<'\n';
E e; cout<<'\n';
F f; cout<<'\n';
}