C++
文章平均质量分 75
feijinxinsi
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
类构造和析构研究
一、代码1(全局类变量) #include <iostream> using namespace std; class A{ public: A(); ~A(); }; A::A(){ std::cout<<"A construct"<<std::endl; } A::~A(){ std::cout<<"A des...原创 2015-02-06 15:07:53 · 122 阅读 · 0 评论 -
i++与++i研究
直接上代码: 1.++i int add(int a, int b) { int c = 0; b = ++c; return a+b; } int init() { int a = add(3, 4); return a; } 对应的汇编如下: _Z3addii: .LFB0: .cfi_startproc pushl %e...原创 2015-06-26 10:56:03 · 125 阅读 · 0 评论 -
函数返回值研究
1.基本类型的返回值 int add(int a, int b) { int c = 0; b = c++; return a+b; } int init() { int a = add(3, 4); return a; } 对应的汇编如下: .file "list initialization.cpp" .text .globl _...原创 2015-06-26 11:23:23 · 197 阅读 · 0 评论 -
C++指针和引用
首先,我在网上搜索了下C++指针和引用的区别,得到的结果大致如下: 1.指针和引用的定义和性质区别: (1)指针:指针是一个变量,只不过这个变量存储的是一个地址,指向内存的一个存储单元;而引用跟原来的变量实质上是同一个东西,只不过是原变量的一个别名而已。如: int a=1;int *p=&a; int a=1;int &b=a; 上面定义了一...原创 2015-06-26 16:54:13 · 110 阅读 · 0 评论 -
Watch out the parsing mechanism of C++ compiler
From the book named <<Effective STL 50 Specific Ways to Improve Your Use of the Standard Template Library>>, I knew the suggestion of " Watch out the parsing mechanism of C++ compiler", ...原创 2015-10-24 13:06:49 · 252 阅读 · 0 评论 -
c++利用属性名设置和获取属性值
/* * @Filename:CMetaDataManager.h * @Date:2016-10-21 * @Author:yuanzuochao * @Description: * * @History: * Date Author Records * 2016-10-21 ...原创 2016-10-21 17:42:29 · 1742 阅读 · 0 评论 -
获取带有虚函数的类的私有变量
今天接触到一道面试题,提供一个类,含有两个私有变量和一个virtual的析构函数,没有提供任何获取私有变量的公共方法,让提取私有变量。代码大致如下: class A { public: A(){} virtual ~A(){} private: int n; double f; }; 我认为核心思路是利用C++的内存对象模型来提取,但是虚表指针...原创 2015-12-23 21:14:07 · 216 阅读 · 0 评论 -
解数独程序
// Soduku.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <map> #include <iostream> #include <set> #include <algorithm> #include <vector> using namespace ...原创 2017-09-05 15:28:55 · 302 阅读 · 0 评论
分享