题目内容

请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程文件proj3。本题创建一个小型字符串类,字符串长度不超过100。程序文件包括proj3.h、proj3.cpp、writeToFile.obj。补充完成重载赋值运算符函数,完成深复制功能。 屏幕上输出的正确结果应该是: Hello! Happy new year! 要求: 补充编制的内容写在“//**********333**********”与“//**********666**********”两行之间。不得修改程序的其他部分。 注意: 程序最后调用writeToFile函数,使用另一组不同的测试数据,将不同的运行结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件。 //proj3.h #include<iostream> #include<iomanip> using namespace std; class MiniString public: friend ostream &operator<< ostream &output,const MiniString &s) //重载流插入运算符 output <<s.sPtr; return output; friend istream &operator>>(istream &input,MiniString &s) //重载流提取运算符 char temp[100];//用于输入的临时数组 temp[0]=’\0’; //初始为空字符串 input>>setw(100)>>temp; int inLen=strlen(temp); //输入字符长度 if(inLen!=0) s.length=inLen; //赋长度 if(s.sPtr!=0)delete[]s.sPtr;//避免内存泄漏 s.sPtr=new char[s.length+1]; strcpy(s.sPtr,temp); //如果s不是空指针,则复制内容 else s.sPtr[0]=’\0’; //如果s是空指针,则为空字符串 return input; void modString const char *string2)//更改字符串内容 if(string2 !=0) //如果string2不是空指针,则复制内容 if (strlen(string2)!=length) length=strlen(string2); delete[]sPtr; sPtr=new char [length+1]; //分配内存 strcpy(sPtr,string2); else sPtr[0]=’\0’; //如果string2是空指针,则为空字符串 MiniString& operator=(const MiniString &otherString); MiniString(const char*s=" "):length((s!=0)strlen(s):0) //构造函数 sPtr=0; if(length!=0) setString(s); ~MiniString()//析构函数 delete[]sPtr; private: int length; //字符串长度 char*sPtr; //指向字符串起始位置 void setString ( const char *string2)//辅助函数 sPtr=new char[strlen(string2)+1]; //分配内存 if(string2 !=0)strcpy(sPtr,string2); //如果string2不是空指针,则复制内容 else sPtr[0]=’\0’; //如果string2是空指针,则为空字符串 ; //proj3.cpp #include<iostream> #include<iomanip> using namespace std; #include "proj 3.h" MiniString& MiniString::operator=(const MiniString &otherString) //重载赋值运算符函数。提示:可以调用辅助函数setString //*************333************* //*************666************* int main() MiniString str1("Hello!"),str2; void writeToFile(const char*); str2=str1;//使用重载的赋值运算符 str2.modString("Happy new year!"); cout<<str1<<’\n’; cout<<str2<<’\n’; writeToFile(" "); return 0;

查看答案
更多问题

食品安全国家标准由国务院卫生行政部门负责制定、公布,国务院标准化行政部门提供国家标准编号。

A. 对
B. 错

For all his vaunted talents, Federal Reserve Chairman Alan Greenspan has never had much of a reputation as an economic forecaster. In fact, he shies away from making the precise-to-the-decimal-point predictions that many other economists thrive on. Instead, he owes his success as a monetary policymaker to his ability to sniff out threats to the economy and manipulate interest rates to dampen the dangers he perceives. Now, those instincts are being put to the test. Many Fed watchers--and some policymakers inside the central bank itself--are beginning to wonder whether Greenspan has lost his touch. Despite rising risks to the economy from a swooning stock market and soaring oil prices that could hamper growth, the Greenspan-led Federal Open Market Committee (FOMC) opted to leave interest rates unchanged on Sept. 24. But in a rare dissent, two of the Fed’s 12 policymakers broke ranks and voted for a cut in rates--Dallas Fed President Robert D. McTeer Jr. and central bank Governor Edward M. Gramlich. The move by McTeer, the Fed’s self-styled "Lonesome Dove", was no surprise. But Gramlich’s was. This was the first time that the monetary moderate had voted against the chairman since joining the Fed’s board in 1997. And it was the first public dissent by a governor since 1995. Despite the split vote, it’s too soon to count the maestro of monetary policy out. Greenspan had good reasons for not cutting interest rates now. And by acknowledging in the statement issued after the meeting that the economy does indeed face risks, Greenspan left the door wide open to a rate reduction in ’the future. Indeed, former Fed Governor Lyle Gramley thinks chances are good that the central bank might even cut rates before its next scheduled meeting on Nov. 6, the day after congressional elections. So why didn’t the traditionally risk-averse Greenspan cut rates now as insurance against the dangers dogging growth For one thing, he still thinks the economy is in recovery mode. Consumer demand remains buoyant and has even been turbocharged recently by a new wave of mortgage refinancing. Economists reckon that homeowners will extract some $100 billion in cash from their houses in the second half of this year. And despite all the corporate gloom, business spending has shown signs of picking up, though not anywhere near as strongly as the Fed would like. Does that mean that further rate cuts are off the table Hardly. Watch for Greenspan to try to time any rate reductions to when they’ll have the most psychological pop on business and investor confidence. That’s surely no easy feat, but it’s one that Greenspan has shown himself capable of more than once in the past. Don’t be surprised if he surprises everyone again. It can be inferred from the passage that ______.

A. instincts most often misguide the monetary policies
B. Greenspan has lost his control of the central bank
C. consensus is often the case among Fed’s policymakers
D. Greenspan wouldn’t tolerate such a dissent

在下列两个案例中各有5个问题,请在各问题答案的选项中,选出一个或一个以上正确答案。 青岛某中外合资企业甲系加工贸易A类企业,于进料对口合同项下从韩国供货商乙处进口一批化纤面料,以CIF青岛50000美元成交。该批货物 2004年4月1日由釜山海运至青岛,面料暂存于青岛某保税仓库丙处。后来,甲从丙处提取面料进行加工,于2005年2月将其制成品全部返销出口。请根据上述事实,请回答下列问题: 甲向海关报核时应提交下列哪些单证()

A. 加工贸易手册
B. 料件进口报关单
C. 制成品出口报关单
D. 不选

在下列两个案例中各有5个问题,请在各问题答案的选项中,选出一个或一个以上正确答案。青岛某中外合资企业甲系加工贸易A类企业,于进料对口合同项下从韩国供货商乙处进口一批化纤面料,以CIF青岛50000美元成交。该批货物 2004年4月1日由釜山海运至青岛,面料暂存于青岛某保税仓库丙处。后来,甲从丙处提取面料进行加工,于2005年2月将其制成品全部返销出口。 请根据上述事实,请回答下列问题: 假设该制成品应当缴纳出口税,且超过规定期限未向海关纳税,海关采取的下列哪些措施是合法的并且是可行的:

A. 以书面或口头方式通知甲的开户银行,从其存款中扣缴税款
B. 将甲的该批出口货物依法变卖,以变卖所得抵缴税款
C. 将甲申报进口的另一批已缴纳税款但尚未放行的货物扣留价值相当于应纳税款的部分,并依法变卖
D. 以书面或口头方式通知A公司的开户银行,冻结其存款

答案查题题库