草庐IT

create_pointer_down

全部标签

c++ - 没有对 'pthread_create' 的匹配函数调用

我正在使用Xcode和C++制作一个简单的游戏。问题出在以下代码:#includevoid*draw(void*pt){//...}void*input(void*pt){//....}voidGame::create_threads(void){pthread_tdraw_t,input_t;pthread_create(&draw_t,NULL,&Game::draw,NULL);//Errorpthread_create(&input_t,NULL,&Game::draw,NULL);//Error//...}但是Xcode给我错误:“没有匹配的函数调用‘pthread_crea

c++ - 为什么我没有 WGL_ARB_create_context 扩展?

我正在执行以下代码来创建核心配置文件OpenGL上下文。具体来说,我是:创建一个虚拟窗口使用这个虚拟窗口请求OpenGL上下文(我假设它会被硬件加速,但我不确定这是否重要)使用这个OpenGL上下文加载OpenGL函数指针使用这些函数指针,然后我尝试使用wglCreateContextAttribsARB在第二个窗口中创建第二个上下文,特别是使用核心配置文件。代码:WNDCLASSWwcDummy={0};wcDummy.lpfnWndProc=+[](HWNDhWnd,UINTmessage,WPARAMwParam,LPARAMlParam){returnDefWindowProc

Docker 一小时从入门到实战 —— Docker commands | Create your own image | vs VM ... 基本概念扫盲

Dockercrashcourse文章目录Dockercrashcourse1.WhatandWhyofDocker?2.1What2.2Whatproblemdoesitsolve?2.2.1beforecontainers2.1.2withcontainers2.DockervsVirtualMachines2.1Difference2.2Benefits3.Installdockerlocally4.ImagesvsContainers5.PublicandPrivateRegistries6.MainDockercommands-pull,run,start,stop,logs,bui

c++ - 标准转换 : Array-to-pointer conversion

这是来自ISO的要点:标准转换:数组到指针的转换:$4.2.1Anlvalueorrvalueoftype“arrayofNT”or“arrayofunknownboundofT”canbeconvertedtoanrvalueoftype“pointertoT.”Theresultisapointertothefirstelementofthearray.谁能解释一下,如果可能的话,用一个示例程序。我已经看过这些链接,但我无法理解:ArrayandRvalueIthinkImayhavecomeupwithanexampleofrvalueofarraytype

C++ 集合 : how to create a map like structure

什么样的收集方法会存储一对(键和值),其中键不是唯一的(我认为从技术上讲它不能成为键)?在我程序的某处我有:typedefstruct{intnKey;stringstrFormType;}KeyPair;然后我将使用此结构将对象存储在vector中。vectorvKeyList;KeyPairMenuOne;MenuOne.nKey=1;MenuOne.strFormType="Window";vKeyList.push_back(MenuOne);MenuOne.nKey=0;MenuOne.strFormType="Window2";vKeyList.push_back(Menu

c++ - 从结构中调用 Pointer-to-Member-Function 指向的函数

我有一个具有特殊数据结构的类Test。Test类的成员是std::map,其中键是std::string,映射值是struct定义如下:typedefstruct{void(Test::*f)(void)const;}pmf_t;map初始化正常。问题是当我试图调用指向的函数时。我编了一个重现问题的玩具示例。在这里:#include#includeusingnamespacestd;classTest;typedefvoid(Test::*F)(void)const;typedefstruct{Ff;}pmf_t;classTest{public:Test(){pmf_tpmf={&T

C++ 问题 : pointers/memory addresses and subclasses

为什么允许我们运行这段代码:int*FunctionB(intx){inttemp=30;//morecodereturn&temp;}在我看来,我并没有像我说过的那样返回。为什么我把返回类型声明为指针就可以返回一个内存地址。指针不是指向内存地址的东西,实际上不是内存地址吗?classImage:publicBMP{public:voidinvertcolors();voidflipleft();voidadjustbrightness(intr,intg,intb);private:};在编译之前的代码时我得到这个错误:image.h:3:error:expectedclass-na

c++ - std::sort 在 std:vector of pointers 上失败

以下代码在对vector进行排序时崩溃。#include#include#includeusingnamespacestd;structFoo{intx;//inty;Foo():x(0){}};structCmp{booloperator()(Foo*p1,Foo*p2)const{if(p1->x!=p2->x)returnp1->xx;//if(p1->y!=p2->y)returnp1->yy;returntrue;}};intmain(){vectorv;for(inti=0;i为什么会这样? 最佳答案 boolopera

c++ - 使用 const 键类型引用调用 std::set of pointers 的 count 方法

我有一个类structS{boolfoo(constAType&v)const{returnvalues.count(&v);//compileerrorduetotheconstnessofv}private:std::setvalues;};这是一个简化版本。在实际代码中,foo做了一些复杂的事情。代码产生错误invalidconversionfrom‘constAType*’to‘std::set::key_type{akaAType*}’我认为foo应该采用'constAType&v'因为它不会改变v。成员变量“values”的类型不能为std::set,因为结构S的某些方法调

c++ - GCC 7,aligned_storage 和 "dereferencing type-punned pointer will break strict-aliasing rules"

我编写的代码在GCC4.9、GCC5和GCC6中没有警告。它在一些较旧的GCC7实验快照(例如7-20170409)中也没有警告。但在最近的快照(包括第一个RC)中,它开始产生关于别名的警告。代码基本上可以归结为:#includestd::aligned_storage::typestorage;intmain(){*reinterpret_cast(&storage)=42;}使用最新的GCC7RC编译:$g++-Wall-O2-cmain.cppmain.cpp:Infunction'intmain()':main.cpp:7:34:warning:dereferencingtyp