笔试题
}
程序输出结果为:
2、第二题#include <iostream>
#include <string.h>
using namespace std;
class Student{
public:
Student(char* pName="no name",int ssId=0)
{
strncpy(name,pName,40);
name[39]='\0';
id = ssId;
cout <<"Constructing new student " <<pName <<endl;
}
Student(Student& s)
{
cout <<"Constructing copy of " << <<endl;
strcpy(name,"copy of ");
strcat(name,);
id=s.id;
}
~Student()
{
cout <<"Destructing " <<name <<endl;
}
protected:
char name[40];
int id;
};
void fn(Student s)
{
cout <<"In function fn()\n";
}
void main()
{
Student randy("Randy",1234);
cout <<"Calling fn()\n";
fn(randy);
cout <<"Returned from fn()\n";
}
程序输出结果为:
3、第三题
#include<iostream>
搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新资格考试认证C++ 外企笔试题(3)全文阅读和word下载服务。
相关推荐: