CPA-21-02 試験問題 46
次のコードをコンパイルして実行しようとするとどうなりますか?
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
int x;
保護されています:
int y;
公共:
int z;
A() { x=1; y=2; z=3; }
};
クラス B : パブリック A {
文字列 z;
公共:
void set() { y = 4; z = "ジョン"; }
void Print() { cout << y << A::z; }
};
int main () {
Bb;
b.set();
b.Print();
0を返します。
}
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
int x;
保護されています:
int y;
公共:
int z;
A() { x=1; y=2; z=3; }
};
クラス B : パブリック A {
文字列 z;
公共:
void set() { y = 4; z = "ジョン"; }
void Print() { cout << y << A::z; }
};
int main () {
Bb;
b.set();
b.Print();
0を返します。
}
CPA-21-02 試験問題 47
次のコードをコンパイルして実行しようとするとどうなりますか?
#include <iostream>
名前空間 std を使用します。
クラスA {
公共 :
void print() {
cout << "A ";
}
};
クラス B {
公共 :
void print() {
cout << "B ";
}
};
int main() {
B sc[2];
A *bc = (A*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
0を返します。
}
#include <iostream>
名前空間 std を使用します。
クラスA {
公共 :
void print() {
cout << "A ";
}
};
クラス B {
公共 :
void print() {
cout << "B ";
}
};
int main() {
B sc[2];
A *bc = (A*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
0を返します。
}
CPA-21-02 試験問題 48
次のコードをコンパイルして実行しようとするとどうなりますか?
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
int x;
保護されています:
int y;
公共:
int z;
A() { x=1; y=2; z=3; }
};
クラス B : パブリック A {
公共:
void set() {
y = 4; z = 2;
}
void Print() {
cout << y << z;
}
};
int main () {
Bb;
b.set();
b.Print();
0を返します。
}
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
int x;
保護されています:
int y;
公共:
int z;
A() { x=1; y=2; z=3; }
};
クラス B : パブリック A {
公共:
void set() {
y = 4; z = 2;
}
void Print() {
cout << y << z;
}
};
int main () {
Bb;
b.set();
b.Print();
0を返します。
}
CPA-21-02 試験問題 49
次のコードをコンパイルして実行しようとするとどうなりますか?
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
保護されています:
int y;
公共:
int x;
int z;
A() { x=2; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x ? よ;}
void Print() {
cout << z;
}
};
int main () {
A a(2,5);
a.Print();
0を返します。
}
#include <iostream>
#include <文字列>
名前空間 std を使用します。
クラスA {
保護されています:
int y;
公共:
int x;
int z;
A() { x=2; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x ? よ;}
void Print() {
cout << z;
}
};
int main () {
A a(2,5);
a.Print();
0を返します。
}
CPA-21-02 試験問題 50
次のコードをコンパイルして実行しようとするとどうなりますか?


