草庐IT

non-main

全部标签

c++推导 "non type pointer to function"类模板参数

考虑一个模板类:templateclassProxy{voidrun(){ReturnTyperet=Fn();//...dosomething...}};//andafunctionsintfn1(){return5;}floatfn2(){return5;}这可以通过使用实例化:Proxyp1;但是显式声明返回值类型似乎是不必要的。我想要实现的是:someProxyInstantationp1;someProxyInstantationp2;不幸的是,我对c++没有任何期望,这似乎是该语言的一个隐藏角落(至少对我而言)。如果我可以从指向函数的指针获取它的类型——类似于:std::t

c++ - main : linking fortran with C++的多重定义

我想编写一个C++程序,从中调用mvndst_()子例程http://www.math.wsu.edu/faculty/genz/software/fort77/mvndstpack.f在Linux上,如果我创建test.cc:extern"C"{intmvndst_(int*,double*,double*,int*,double*,int*,double*,double*,double*,double*,int*);};intmain(){return0;}并编译通过g++-c-otest.otest.ccgfortran-c-omvndstpack.omvndstpack.fgf

c++ - begin() 如何知道要返回哪种返回类型(const 或 non-const)?

这非常有效:listl;list::const_iteratorit;it=l.begin();list::iteratorit2;it2=l.begin();我不明白list是怎么来的“知道”它必须返回iteratorbegin()版本或const_iteratorbegin()const一个。我正在尝试为我的容器(一个trie)实现迭代器,但我遇到了这个问题。难道C++不应该不按返回类型处理差异化(除非使用奇怪的技巧)?这是一些代码和我得到的编译器错误:我的Trie是一个模板化的trie,可以包含任何类型。我有一个Trie::iter非常量迭代器和一个Trie::const_ite

c++ - 程序关闭时 Windows 是否会自动释放内存(不从 main 返回)?

这个问题在这里已经有了答案:Isitacceptablenottodeallocatememory(19个回答)关闭9年前。当程序关闭时,分配的新内存是否总是被释放?(即使由于错误/错误等或自定义关闭函数而意外关闭)?还是仅在从main返回时才释放内存?

c++ - 大括号和main方法中的返回值

这个问题在这里已经有了答案:Nocurlybracesaroundmain()--whydoesthiswork?(6个答案)关闭9年前。我读了这个code(BjarneStroustrup)。我很困惑...main函数体不在{}中,函数不返回值(作为int)。而且它有效……为什么?#include"std_lib_facilities.h"intmain()try{cout>val1>>op>>val2){//readnumberoperationnumberstringoper;doubleresult;switch(op){case'+':oper="sumof";result=

c++ - 该程序在 main() 上的 'return;' 之后需要很长时间才能关闭

这是我正在处理的代码:#include#includeusingnamespacestd;staticunsignedlongcollatzLength(unsignedlongn){staticstd::mapcollatzMap;intmapResult=collatzMap[n];if(mapResult!=0)returnmapResult;if(n==1){return1;}else{collatzMap[n]=1+collatzLength(n%2==0?n/2:3*n+1);returncollatzMap[n];}}intmain(){intmaxIndex=1;uns

c++ - 'non-virtual interface' 和 'abstract interface' 有什么区别?

我正在用C++实现设计模式,我希望我的类通过组合来利用接口(interface),这让我研究了实现接口(interface)的不同方法。我想澄清一下这个术语的定义。 最佳答案 非虚拟接口(interface)是一个公共(public)成员函数,它不是虚拟的,但通常希望根据可覆盖的虚拟函数来实现:classInterface{public:intcompute(){returncompute_impl();}private:virtualintcompute_impl()=0;protected:virtual~Interface()

python - python脚本能否知道Android环境下C++main函数的返回值

有几种调用C++可执行程序的方法。例如,我们可以使用defrun_exe_return_code(run_cmd):process=subprocess.Popen(run_cmd,stdout=subprocess.PIPE,shell=True)(output,err)=process.communicate()exit_code=process.wait()printoutputprinterrprintexit_codereturnexit_code处理一个C++可执行程序:run_exe_return_code('abc')而abc是由以下C++代码创建的:intmain()

c++ - 来自 Voronoi 的 Delaunay boost : missing triangle with non-integral point coordinates

遵循这两个资源:BoostbasictutorialSOQuestion我用boost写了一个Delaunay三角剖分。如果点坐标是完整的(我生成了几个随机测试并且我没有观察到错误),它工作正常。但是,如果这些点不是整数,我会发现许多不正确的三角剖分缺少边缘或错误的边缘。例如这张图片是用四舍五入的值构建的并且是正确的(见下面的代码)但是这个图像是用原始值构建的并且是不正确的(见下面的代码)这段代码重现了这两个例子(没有显示)。#includeusingboost::polygon::voronoi_builder;usingboost::polygon::voronoi_diagram

c++ - 尝试构建共享库 g++/mac 时 undefined symbol _main

我正在尝试在Mac上构建libdecodeqr。我的C++构建和链接历史都在Windows上,所以这是一个令人兴奋的发现之旅。我终于到了要创建链接库的地步。我正在运行的命令是:g++-shared-olibdecodeqr.so.0.9.3bitstream.ocodedata.ocontainer.oecidecoder.oformatinfo.ogalois.oimagereader.olibdecodeqr.o-L/opt/local/lib-archi386-lcxcore-lcv结果是:Undefinedsymbols:"_main",referencedfrom:start