找考题网-背景图
未分类题

有如下程序: #include <iostream.h> using namespace std; class Stack { public: Stack (unsigned n=10):size (n) {rep_=new int [size]; top=0;} Stack (stack&s}: size (s.size) { rep_new int[size]; for (int i=0;i<size;i++ rip_[i]-s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void poush (int a) {rep_[topj=a; top++;} int pep() { --top; return rep_[top];} bool isEmpty() cons5 [return Top ==0;} private: int*rep_; unsigned size, top; }; int main() { Stack s1; for(int i=1;i<5;i++) s1.push(i); Stack s2(s1); for(i=1;i<3;i++} cout<<s2.pop()<<','; s2.push(6); s1.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; } 执行上面程序的输出是
A.4,3,2,1,
B.4,3,6,7,2,1,
C.4,3,6,2,1,
D.1,2,3,4,

A.h>
B.size)
C.rep_[i];
D.top;
E.push(i);
F.pop()<<',';
G.push(6);
H.push(7);
I.isEmpty())
J.pop()<<',';
K.4,3,2,1,
B.4,3,6,7,2,1,
C.4,3,6,2,1,

【参考答案】

C
解析:本题是一个综合应用考题,考核知识点包括类与对象的应用(包括构造函数、拷贝构造函数),循环语句的使用、指针的使用。 分析程序:类Stack的构造函数中默认参数为 10,即构造大小为10的堆栈,成员函数push用于将数据压入堆栈中,pop用于将数据弹出堆栈。主函数main中,先定义了类...

(↓↓↓ 点击‘点击查看答案’看完整答案 ↓↓↓)
热门试题

未分类题It has been justly said that while' we speak with our vocal organs we (1)_____ with our whole bodies'. All of us communicate with one another (2)_____, as well as with words. Sometimes we know what we're doing, as with the use of gestures such as the thumbs-up sign to indicate that, we (3)_____. But most of the time we're not aware that we're doing it. We gesture with eyebrows or a hand, meet someone else's eyes and (4)_____. These actions we (5)_____ are random and incidental. But researchers (6)_____ that there is a system of them almost as consistent and comprehensible as language, and they conclude that there is a whole (7)_____ of body language, (8)_____ the way we move, the gestures we employ, the posture we adopt, the facial expression we (9)_____, the extent to which we touch and the distance we stand (10)_____ each other.The body language serves a variety of purposes. Firstly it can replace verbal communication, (11)_____ with the use of gesturE.Secondly it can modify verbal communication, loudness and (12)_____ of voice is an example herE.Thirdly it regulates social interaction: turn taking is largely governed by non-verbal (13)_____. Finally it conveys our emotions and attitudes. This is (14)_____ important for successful cross-culture communication.Every culture has its own' body language', and children absorb its nuances (15)_____ with spoken languagE.The way an Englishmen crosses his legs is (16)_____ like the way a mate American does it. When we communicate with people from other, cultures, the body language sometimes help make the communication easy and (17)_____, such as shaking hand is such a (18)_____ gesture that people all over the world know that it is a signal for greeting. But sometimes—the body language can cause certain misunderstanding (19)_____ people of different cultures often have different forms behavior. for sending the same message or have different (20)_____ towards the same body signals.A.addressB.reverseC.converseD.confer

A.B.
C.
A.address
B.reverse
C.converse