
编程语言
jiyanfeng1
喜欢算法和编程的工科男
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++虚函数表面试汇总
C++虚函数表面试汇总一般来说,对于开发者我们只需要知道虚函数的使用方法,以及虚函数表的存在即可。但面试时往往会遇到更细节的问题,比如让你实现一个虚函数机制,虽然不太实用,总归了解些底层知识也是件好事。但如果有人苦苦相逼一定要拿这个刷人,你就去骂他吧,你才是写编译器的,你们全家都是写编译器的。唉,我有些失态了... 1. 虚函数与虚函数表基本知识这里有一篇介绍,只需看前两页,各种配转载 2012-09-27 06:30:29 · 1158 阅读 · 0 评论 -
利用函数申请内存的几个问题
本文转自:http://buptdtt.blog.51cto.com/2369962/832201在下面的例子中,GetMemory1是想通过形参返回动态申请的内存的地址,这个时候只能用二重指针,如GetMemory2所示。还可以通过return语句将申请的内存地址返回,即:把GetMemory1的返回值类型改成char*,在函数体内添加语句: return p;。#include转载 2012-11-22 09:47:05 · 1075 阅读 · 0 评论 -
C++特性
1. Multiple inheritance: http://www.learncpp.com/cpp-tutorial/117-multiple-inheritance/2. Virtual Base Class: http://www.learncpp.com/cpp-tutorial/118-virtual-base-classes/3. Pointers and Referenc原创 2012-10-11 03:47:30 · 541 阅读 · 0 评论 -
全面整理的C++面试题(II)
1. 指针和引用有什么区别?A pointer can be re-assigned any number of times while a reference can not be reassigned after initialization.A pointer can point to NULL while reference can never point to NULLYou原创 2013-01-28 13:55:26 · 519 阅读 · 0 评论 -
smart pointer / shared pointer / normal pointer
smart pointer / shared pointer / normal pointer文章来源:http://stackoverflow.com/questions/417481/pointers-smart-pointers-or-shared-pointersI am programming with normal pointers, but I have heard转载 2013-02-07 01:29:10 · 647 阅读 · 0 评论 -
java:reference C++:pointer
In C++, object variables hold object values. This is different from Java, where an object variable only is a reference to an object value that is stored elsewhere. There are circumstances where the sa翻译 2013-02-16 06:51:23 · 771 阅读 · 0 评论 -
C/C++ Programming interview questions and answers
What is encapsulation??Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates the internal complexity of an object's operation from th转载 2012-09-27 23:19:00 · 2188 阅读 · 0 评论 -
c++ bit field
Bit fieldDeclares a class data member with explicit size, in bits. Adjacent bit field members may be packed to share and straddle the individual bytes.A bit field declaration is a class data转载 2014-09-19 02:34:20 · 1589 阅读 · 0 评论 -
用C++实现一个不能被继承的类
题目:用C++设计一个不能被继承的类 不能被继承?不能被继承?按照继承的理论知识分析,我们只要把类的构造函数设置为私有的,即可解决问题。因为那样的话,子类就没有办法访问基类的构造函数,从而就阻止了进行子类构造对象的任务实现,也就达到了不可继承的目的。 但是,假设那样,这个类我们怎么使用呢?那这样子给我们的利用也造成了一定的障碍。好了。你是不是也想到了,定义静态方法,在方法内原创 2012-10-03 12:48:47 · 2785 阅读 · 0 评论 -
A Quiz About Integers in C
A Quiz About Integers in CYou scored 0 out of 20. Note: Sometimes scores are reported incorrectly -- sorry about that. I think it's a bug in the quiz plugin for WP that I'm using. I转载 2014-11-01 07:49:06 · 1089 阅读 · 0 评论 -
struct 结构体的大小
struct s1 { char ch, *ptr; union { short a, b; unsigned int c:2, d:1; } struct s1 *next; }; 的大小是_____: A. 12字节 B.16字节 C.20字节 D. 24字节原创 2014-09-19 03:09:47 · 1050 阅读 · 0 评论 -
全面整理的C++面试题(I)
1. 是不是一个父类写了一个virtual 函数,如果子类覆盖它的函数不加virtual ,也能实现多态?virtual修饰符会被隐形继承的。virtual可加可不加子类覆盖它的函数不加virtual ,也能实现多态。2. 请简单描述Windows内存管理的方法。当程序运行时需要从内存中读出这段程序的代码。代码的位置必须在物理内存中才能被运行,由于现在的操作系统中有非常多的原创 2013-01-27 12:42:44 · 789 阅读 · 0 评论 -
STL list "list iterator not incrementable"
这几天在vc.net下写一个小东西,涉及到list的使用.程序运行到使用erase删除list中某个元素的时候,会弹出异常对话框,提示的异常为:”list iterator not incrementable”.调试检查半天无果,就特意写了一个小程序测试:#include #include #include using namespace std; int main() {转载 2012-11-22 15:40:23 · 5517 阅读 · 0 评论 -
syntax和semantics的区别
syntax研究的是句法,或者说是语言的结构,这无关乎语言实体的含义。semantics研究的是语义/含义。对于同一个的语义,不同的语言会采用不同的句法来构成句子。例如:x += yC, C++, C#, Java, Perl, Python, Ruby, PHP, etc.x := x + yALGOL, BCPL, Simul原创 2012-11-13 13:35:03 · 14977 阅读 · 0 评论 -
请自己写出strcpy函数
char s[100]="1234"; strcpy(s+3,s); printf("%s",s); 输出结果是1231234234 不理解这是为什么? ------------------------------------------------ 已知strcpy函数如下所示:char * strcpy(char *dest, char *source) {原创 2012-11-12 15:09:42 · 5583 阅读 · 0 评论 -
与C++特性相关的面试题
1. static在c,c++中有什么不同点2. 堆和栈的区别3. 纯虚函数4. 指针和引用的区别5. 如果构造函数出错,如何处理?6. 对设计模式是否熟悉,用过哪些?7. c++如何使用c中的函数,为什么?整理:1.静态数据成员/成员函数,C++特有2.略3.在面向对象的C++语言中,虚函数(virtual func转载 2012-09-27 11:07:59 · 1813 阅读 · 0 评论 -
Volatile的作用
volatile的作用 volatile的作用: 作为指令关键字,确保本条指令不会因编译器的优化而省略,且要求每次直接读值. 简单地说就是防止编译器对代码进行优化.比如如下程序: XBYTE[2]=0x55; XBYTE[2]=0x56; XBYTE[2]=0x57; XBYTE[2]=0x58;转载 2012-10-12 04:11:33 · 1140 阅读 · 0 评论 -
C语言中static变量详解
Static翻译出来是“静态”“静止”的意思,在C语言中的意思其实和它的本意差不多,表示“静态”或者“全局”的意思,用来修饰变量和函数。经static修饰过后的变量或者函数的作用域或者存储域会发生变化,而由static修饰的变量在初始值方面也会表现出static关键字的优势。想知道经static修饰过后的变量或者函数的作用域或者存储域发生了什么变化吗,发生变化的原因是什么吗?请大家继续往下看!转载 2012-09-25 08:54:48 · 1198 阅读 · 0 评论 -
C++多维数组参数
如何正确的将多维数组作为参数传递给函数。void ThisIsIllegal(int arr[][]); // Wrong!void ThisIsAlsoIllegal(int arr[10][]); // Also wrongvoid ThisIsIllegal(int arr[][10]); // OkayThe problem is that when passing multidi原创 2012-10-16 10:02:07 · 645 阅读 · 0 评论 -
C++ 特性 面试
1. C++的特点有哪些?面向对象应该涉及到了,封装,继承,多态,重载,应该是基本功能,现在很多面向对象的语言都有这些功能了。 特点我觉得应该是泛型吧! 还有metaprogramming!原创 2012-10-17 04:49:07 · 1993 阅读 · 0 评论 -
为什么strcpy的返回值是char* ?
当我在笔试中面对这个题目的时候,毫不犹豫的写下这样的答案:如果strDest的长度小于strSrc,会删除strDest,然后new一块与strSrc相同大小的内存。由于我知道试题是出自林锐的《高质量C++编程指南》,所以回来后我查看了相关的资料,结果大失所望,以下是引自原文:【建议6-2-1】有时候函数原本不需要返回值,但为了增加灵活性如支持链式表达,可以附加返回值。转载 2012-10-18 23:49:49 · 17154 阅读 · 1 评论 -
【C/C++学习】之十五、内存管理
索引:1、内存分配简介2、内存分配常见错误3、new()/delete()函数的使用4、malloc()/free()函数的使用在C++中,内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量存储区。栈,就是那些由编译器在需要的时候分配,在转载 2012-10-19 09:15:30 · 2393 阅读 · 0 评论 -
Python Yield versus Return
As coders, we are familiar with how function calls work in Python or C. Whenever we call a function, the function gets a private namespace where its local variables are created.ReturnThe return s转载 2012-11-05 13:30:25 · 2024 阅读 · 0 评论 -
The power of Python's yield
Computing permutationsWhat is a permutation? Reading from my local copy of Wikipedia: Permutation is the rearrangement of objects or symbols into distinguishable sequences. Each unique转载 2012-11-05 13:33:14 · 1630 阅读 · 0 评论 -
Python docstring文档字符串
使用DocStringsPython有一个很奇妙的特性,称为 文档字符串,它通常被简称为 docstrings 。DocStrings是一个重要的工具,由于它帮助你的程序文档更加简单易懂,你应该尽量使用它。你甚至可以在程序运行的时候,从函数恢复文档字符串!使用DocStrings例7.8 使用DocStrings#!/usr/bin/python# Filename:转载 2012-10-27 06:10:56 · 15160 阅读 · 0 评论 -
Python Generator
Generators functions allow you to declare a function that behaves like an iterator, i.e. it can be used in a for loop.Simplified CodeThe simplification of code is a result of generator f转载 2012-11-06 13:47:03 · 2374 阅读 · 0 评论 -
C++ Memory Management C++ 内存管理
ProblemC++ has several distinct memory areas where objects and non-object values may be stored, and each area has different characteristics.Name as many of the distinct memory areas as you can. Fo转载 2015-08-12 04:41:23 · 1084 阅读 · 0 评论