热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

模拟考试

设为首页

收藏此页面

订阅邮箱地址

C++ 面试题与答案

Test your skills through the online practice test: C++ Quiz Online Practice Test

相关差异对比

C vs C++Java vs C++

问题 11. What is public, protected, private?

Public, protected and private are three access specifier in C++.
Public data members and member functions are accessible outside the class.
Protected data members and member functions are only available to derived classes.
Private data members and member functions can?t be accessed outside the class. However there is an exception can be using friend classes.
Write a function that swaps the values of two integers, using int* as the argument type.
void swap(int* a, int*b) {
int t;
t = *a;
*a = *b;
*b = t;
}

这有帮助吗? 添加评论 查看评论
 

问题 12. Tell how to check whether a linked list is circular.


Create two pointers, each set to the start of the list. Update each as follows:

这有帮助吗? 添加评论 查看评论
 

问题 13. OK, why does this work?


If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, it?s either 1 or 2 jumps until they meet.

这有帮助吗? 添加评论 查看评论
 

问题 14. What is virtual constructors/destructors?


Answer1
Virtual destructors:
If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
There is a simple solution to this problem declare a virtual base-class destructor.
This makes all derived-class destructors virtual even though they don?t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error.

Answer2
Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching the pointer type) is called on the object.
There is a simple solution to this problem ? declare a virtual base-class destructor. This makes all derived-class destructors virtual even though they don?t have the same name as the base-class destructor. Now, if the object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived-class object, the destructor for the appropriate class is called.

这有帮助吗? 添加评论 查看评论
 

问题 15. Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance?


Yes.

这有帮助吗? 添加评论 查看评论
 

2) Tell how to check whether a linked list is circular. 3) OK, why does this work? 4) What is virtual constructors/destructors? 5) Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance? " />

用户评价最有帮助的内容:

版权所有 © 2026,WithoutBook。