C++软件工程师笔试题附答案

鼎易C++软件工程师笔试题

(笔试时间60分钟)

 

职位____________ 姓名_____________性别____________日期____________

 

 

一、选择题(1*9=9分) 

1.如果派生类以proctected方式继承基类,则原基类的protected和public成员在派生类的访问性分别是:(   D   

A.public和public

B.public和protected

C.protected和public

D.protected和protected 

 

2.派生类的成员函数不能访问基类的:(   C   

A.共有成员和保护成员

B.共有成员

C.私有成员

D.保护成员 

 

3.按照“后进先出”原则组织数据的数据结构是(  B  

A.队列

B.栈 

C.双向链表

D.二叉树 

 

4.下列关于虚函数的说明中,正确的是:(   B   

A.从虚基类继承的函数都是虚函数

B.虚函数不得是静态成员函数 

C.只能通过指针或者引用调用虚函数

D.抽象类中的中的成员函数都是虚函数。 

 

5.有如下类的定义:

Class MyClass 

{

int value; 

public: MyClass(int n):value(n){} 

int getValue() const {return value;}

}

则类Myclass的构造函数的个数是:(   B  

A1

B2

C3

D4

 

6.有如下类的定义:

class Constants

{  

public:   static double GetPI(void){return 3.14159;}

};  

Constants constants;

下列各组语句中,能输出3.14159的是: (   D  

A.cout<<constants->GetPI();和cout<<Constants::GetPI();  

B.cout<<constants.GetPI();和cout<<Constants.GetPI();  

C.cout<<constants->GetPI();和cout<<Constants->GetPI();  

D.cout<<constants.GetPI();和cout<<Constants::GetPI();

 

7.有如下程序: 

#include <iostream> 

using namespace std; 

class VAC

{  

public:   int f() const{return 3;}  

int f(){return 5;}

};

 int main()

{   

VAC v1;   

const VAC v2;   

cout<<v1.f()<<v2.f();

 return 0;

}  

运行时的输出结果是:   A  

A.53   

B.35

C.55   

D.33

 

8.有如下类声明:

class Base

{  

protected:   

int amount;

public:  

Base(int n = 0):amount(n){}   

int getAmount() const {return amount;}

};  

class Derived:public Base

{  

protected:  

int value;

public:   Derived(int m, int n):value(m),Base(n){}  

int getData() const {return value + amount;}

};  

已知x是一个Derived对象,则下列表达式中正确的是: (   B  

A.x.value + x.getAmount();  

B.x.getData() + x.getAmount();

C.x.getData() – x.amount;  

D.x.value + x.amount;

 

9,下列关于Windows应用程序对鼠标响应的说法,正确的是:(  B  )  

A,只有活动窗口才能接受鼠标事件   

B,可以调用函数SetCapture()实现对鼠标的捕捉,且捕捉鼠标后系统的键盘功能暂时失效  

C,用户只能调用系统定义的鼠标的光标形状,不能自定义光标  

D,可以通过相应单一类型的鼠标消息来响应鼠标的拖动事件

 

二、填空题(36分)

1. 某32位系统下, C++程序,请计算sizeof 的值

char str[] = “www.bishiti.com”;

char *p = str ;

int n = 10;

sizeof (str ) =( 16 )  (2分)

sizeof ( p ) =( 4 )    (2分)

sizeof ( n ) = ( 4 )   (2分)

void Foo ( char str[100])

{   

sizeof( str ) =( 4  (2分)

}   

void *p = malloc( 100 );   (2分)

sizeof ( p ) =( 4 )     (2分)

 

2.写出下面程序的输出结果

(1)

void GetMemory(char **p, int num)

{

*p = (char *)malloc(num);

}

void Test(void)

{

 char *str = NULL;

 GetMemory(&str, 100);

 strcpy(str, "hello");

 printf(str);  //输出_____hello________   (3分)

}

 (2)

 void Test(void)

{

 char *str = (char *) malloc(100);

 strcpy(str, “hello”);

 free(str);

 if(str != NULL)

{

 strcpy(str, “world”);

 printf(str);   //输出______异常__________   (3分)

}

}

(3)

 char *GetMemory(void)

{

 char p[] = "hello world";

 return p;

}

void Test(void)

{

 char *str = NULL;

 str = GetMemory();

 printf(str);   //输出_____异常_________ (3分)

}

 

3用变量a给出下面的定义 
a) 一个整型数 

_______________________(1)
b) 一个指向整型数的指针 

_______________________(1)
c) 一个指向指针的的指针,它指向的指针是指向一个整型数 

_______________________(2)
d) 一个有10个整型数的数组

_______________________(1) 
e) 一个有10个指针的数组,该指针是指向一个整型数的 

_______________________(2) 
f) 一个指向有10个整型数数组的指针 

_______________________(2) 
g) 一个指向函数的指针,该函数有一个整型参数并返回一个整型数

_______________________(3) 

h) 一个有10个指针的数组,该指针指向一个函数,该函数有一个整型参数并返回一个整型数

_______________________(3) 

答案: 
a) int a;
b) int *a;

c) int **a;

d) int a[10];

e) int *a[10]; 
f) int (*a)[10]; 
g) int (*a)(int); 
h) int (*a[10])(int);

 

三、简答题(20分)

1.写出MFC中,窗体创建的过程(10分)

 

 

 

 

 

 

 

2. SendMessagePostMessage的区别4分)

 

 

 

 

 

3.const 有什么用途?(请至少说明三种)(6分)

 

 

 

 

 

 

 

四、编程题(20分)

1. 用递归算法判断数组a[N]是否为一个递增数组。递归的方法,记录当前最大的,并且判断当前的是否比这个还大,大则继续,否则返回false结束:(10分)

bool fun( int a[], int n )

{

if( n= =1 )

return true;

if( n= =2 )

return a[n-1] >= a[n-2];

return fun( a,n-1) && ( a[n-1] >= a[n-2] );

 

2.编写一个计算一年有多少秒的函数,输入的是年份(如:2017),返回秒数(2017年总秒数)。(10分)

 

 

 

 

 

 

 

 

五、问题答题(15分)

 

1..写出你对面向对象和程序设计的理解。(10分)

 

 

 

 

 

 

 

 

 

2.简要写出你使用过的设计模式及场景。(5分)



哈哈,这次把名字都放出来了,欢迎来面试,假如你真看到这个,至少你赚到了,第一关不就过了偷笑

评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

keivin2006

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值