问题 单项选择题

有如下程序:
#include<iostream>
#include<string>
using namespace std;
class Instrument
public:
Instrument(string t="乐器",string n="无名"):type(t),name(n)
virtual string GetType() constreturn"乐器";
virtual string GetName() constreturn"无名";
protected:
stnng type,name;
;
class Piano:public Instrument
public:
Piano(string n,string t="钢琴"):lnstrument(t,n)
string CetType() constreturn"钢琴";
string GetName() constreturn name;
;
int main()
Instrument * pi=new Piano("星空");
cout<<pi->GetType()<<’-’<<pi->GetName();
delete pi;
return 0;

运行时的输出结果是______。

A.钢琴-星空
B.钢琴-无名
C.乐器-星空
D.乐器-无名

答案

参考答案:A

解析: 本题考查虚函数的运用,本题中基类Instrument,派生类Piano,其中虚函数为GetType,当定义Instrument*pi=new Piano("星空")时,调用派生类的GetType函数,得到type为钢琴,name为星空,所以输出钢琴-星空。选项A正确。

填空题

Some consumer researchers distinguish_____(1) "rational" motives and "emotional" (or "non-rational") motives. They use the term "rationality"_____(2) the traditional economic sense that assumes_____(3) consumers behave rationally when they carefully consider all alternatives_____(4) choose those that give them the greatest utility (i.e., satisfaction). _____(5) a marketing context, the term "rationality" implies that the consumer selects goods based_____(6) totally objective criteria, such_____(7) size, weight, price, and so on. "Emotional" motives imply the selection of goods____(8) to personal or subjective criteria — the desire_____(9) individuality, pride, fear, affection or status.The assumption underlying this distinction is____(10) subjective or emotional criteria do not maximize utility or satisfaction. _____ (11), it is reasonable to assume that consumers always attempt to select alternatives that, ____(12) their view, serve to maximize satisfaction. Obviously, the assessment of satisfaction is a very personal process, based_____(13) the individual’’s own needs as_____(14) as on past behavioral, social, and learning experiences. What may appear_____(15) irrational to an outside observer may be perfectly rational ______(16) the context of the consumer’’s own psychological field. For example, a product purchased to enhance one’’s self-image (such as a fragrance) is a perfectly rational form of consumer behavior. ____(17) behavior did not appear rational to the person who undertakes it_____ (18) the time that it is undertaken, obviously he or she would not do it._____(19) the distinction between rational and emotional motives does not appear to be warranted.Some researchers go so far_____(20) to suggest that emphasis_____ (21) "needs" obscures the rational, or conscious, nature of most consumer motivation. They claim that con sumers act consciously____(22) maximize their gains and minimize their losses; that they act not____(23) subconscious drives but from rational preferences,____(24) what they perceive to be_____(25) their own best interests.

问答题 论述题