![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
文章平均质量分 70
zheng2263
这个作者很懒,什么都没留下…
展开
-
类字节大小,字节对齐相关
1、空类为1字节,析构函数为4字节,子类在父类的字节大小上面累加class B{ double a; //8字节 int b;public: virtual ~B(){ cout << "B::~B()" << endl; }};class D : public B{ int i; int j;public: virtual ~D() { cout << "D::~原创 2015-12-08 23:25:54 · 471 阅读 · 0 评论 -
dll笔记
int main(){ typedef void(*func)(); HINSTANCE h = LoadLibraryEx(_T("dlltest.dll"), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (h) { func f = (func)GetProcAddress(h, "test");原创 2016-04-26 22:41:32 · 240 阅读 · 0 评论 -
messagepack 初试
本来想玩protocbuf的可是3.0版本的弄了一个早上,在window上都无法编译,就试玩了下messagepack。messagepack直接下源码用vs编译,一次通过。下面直接贴上例子。// msgPack.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include #include cla原创 2016-02-19 17:07:03 · 545 阅读 · 0 评论 -
future, packaged_task promise
#include "stdafx.h"#include #include #include //future 类型#include #include //accumulatetemplate int sum(RAIter beg, RAIter end){ auto len = end - beg; if (len < 1000) return std::acc转载 2015-12-04 00:26:47 · 283 阅读 · 0 评论 -
call_once
std::once_flag flag1void simple_do_once(){ std::call_once(flag1, [](){ std::cout << "Simple example: called once\n"; });}原创 2015-12-02 21:24:21 · 300 阅读 · 0 评论 -
Thread lock_guard 和 unique_lock
#include "stdafx.h"#include #include #include int i;std::mutex i_mutex;struct Box { explicit Box(int num) : num_things{ num } {} int num_things; std::mutex m;};void safe_increment(){原创 2015-12-02 21:18:19 · 374 阅读 · 0 评论 -
c++笔记 Thread
// CTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include void f1(int n){ for (int i = 0; i < 5; ++i) { std::cout << "Thread 1 executing\n"; ++n; std::this_thread::sleep_for(s原创 2015-12-01 23:56:35 · 424 阅读 · 0 评论 -
c++输入
char str[100];cin.getline(str,100);cout str[0] = cin.get() 只读取一个原创 2015-11-22 20:09:30 · 238 阅读 · 0 评论 -
boost库中 不同版本载入lib的方式
boost并不需要我们手动载入lib, 因为其在boost\config\auto_link.hpp中按宏进行了设置。 // vc11:# define BOOST_LIB_TOOLSET "vc110"# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900) // vc12:# define BOOST_LI原创 2016-01-17 20:42:48 · 1916 阅读 · 0 评论 -
一些网上的题目
1、void funa(const int& a, const int& b){cout cout }int main(){int i = 0;funa(++i, i++);}——————————————————————这个根据不同的编译器会有不同的结果:vs:2 0 vs的方法参数是右向左入栈换成java的话是:0 1 与vs相反原创 2015-12-10 20:23:34 · 271 阅读 · 0 评论 -
reinterpret_cast<T>() static_cast<T>() const_cast<T>() dynamic_cast<T>()
reinterpret_cast()从指针类型到一个足够大的整数类型从整数类型或者枚举类型到指针类型从一个指向函数的指针到另一个不同类型的指向函数的指针从一个指向对象的指针到另一个不同类型的指向对象的指针从一个指向类函数成员的指针到另一个指向不同类型的函数成员的指针从一个指向类数据成员的指针到另一个指向不同类型的数据成员的指针以在任意指针之间进行互相转换,即原创 2015-12-14 21:09:37 · 600 阅读 · 0 评论 -
c#程序调用c++dll
最近用dll封装qq游戏大厅的接口,供c#程序调用。封装dll大同小异,也什么问题,问题出在c++和c#间传递的参数问题。1 参数对应,网上很多,我用的是const char* 与 string进行对应,直接用json格式进行解析和封装2 主要问题出先在回调函数上,调用后总是崩溃报错Run-Time Check Failure #0 - The value of ESP was not原创 2017-01-06 11:43:18 · 311 阅读 · 1 评论