小编pro*_*eek的帖子

g ++模板参数错误

我有GetContainer()函数如下.

template<typename I,typename T,typename Container>
Container& ObjCollection<I,T,Container>::GetContainer()
{
    return mContainer;
}
Run Code Online (Sandbox Code Playgroud)

当我使用这个方法如下

template<typename I,typename T>
T& DynamicObjCollection<I,T>::Insert(T& t)
{
    GetContainer().insert(&t);
    return t;
}
Run Code Online (Sandbox Code Playgroud)

我有错误.

error: there are no arguments to ‘GetContainer’ that depend on a template parameter, 
so a declaration of ‘GetContainer’ must be available

error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of 
an undeclared name is deprecated)
Run Code Online (Sandbox Code Playgroud)

它适用于MSVC,但g ++不是那么宽容.代码有什么问题?

c++ templates g++

16
推荐指数
1
解决办法
1万
查看次数

为什么在将C#代码编译成IL时会创建.ctor()?

有了这个简单的C#代码,我就跑了csc hello.cs; ildasm /out=hello.txt hello.exe.

class Hello
{
    public static void Main()
    {
        System.Console.WriteLine("hi");
    }
}
Run Code Online (Sandbox Code Playgroud)

这是来自ildasm的IL代码.

.class private auto ansi beforefieldinit Hello
       extends [mscorlib]System.Object
{
  .method public hidebysig static void  Main() cil managed
  {
    .entrypoint
    // Code size       13 (0xd)
    .maxstack  8
    IL_0000:  nop
    IL_0001:  ldstr      "hi"
    IL_0006:  call       void [mscorlib]System.Console::WriteLine(string)
    IL_000b:  nop
    IL_000c:  ret
  } // end of method Hello::Main

  .method public hidebysig specialname rtspecialname 
          instance void  .ctor() cil managed
  {
    // Code size       7 (0x7) …
Run Code Online (Sandbox Code Playgroud)

c# il csc ildasm

16
推荐指数
2
解决办法
1万
查看次数

在C#中明确实现接口与实现接口

我在VS2010中有两个用于实现接口的选项.

在此输入图像描述

当我有IHelper.cs接口时如下:

public interface IHelper
    ....
    IEnumerable<IPort> Ports { get; }
Run Code Online (Sandbox Code Playgroud)

"显式实现接口"给出了以下代码:

    IEnumerable<IPort> IHelper.Ports
    {
        get
        {
            ...
        }
    }
Run Code Online (Sandbox Code Playgroud)

并且,"实现接口"给了我这个代码:

    public IEnumerable<IPort> Ports
    {
        get
        {
            ...
        }
    }
Run Code Online (Sandbox Code Playgroud)

它们是相同还是不同?为什么我在C#中实现接口有两种选择?

c# interface visual-studio-2010 visual-studio

16
推荐指数
3
解决办法
5058
查看次数

如何在Mac OS X上从命令行进行配置?

我试图使用命令行工具在Mac OS X配置文件的C/C++代码,我使用-pg与选项gcc来运行gprof在Linux上,但我似乎无法找到gprof在Mac上,即使我有这个页面的说明:其他命令行工具(iOS)其他命令行工具(mac).

gprof:Produces execution profiles based on an execution analysis of a program.
Run Code Online (Sandbox Code Playgroud)

我安装的命令行工具,所以其他的命令行工具,如otoolatos可用.我用谷歌搜索这个页面(https://apple.stackexchange.com/questions/154289/installing-gprof-on-mac),说不gprof支持,但我不确定我什么时候有一个描述该工具的Apple doc ; 无论如何,我试图用来brew下载gprof,但它没有用.

我发现尝试在Mac上使用带有C++代码的gprof,但我没有输出instruments -t.我还在mac os x上发现了profiling c ++,但我不想打开Instruments,因为我想自动化一些进程并尝试保持跨平台系统.

  • 如何在Mac OS X上使用gprof?我使用OS X 10.10.
  • 如何在命令行中进行配置,无论是否有gprof

c c++ macos profiling gprof

16
推荐指数
3
解决办法
6833
查看次数

有没有办法在SQLite中存储一个(唯一的)数据元素?

我需要使用SQLite数据库文件作为存储信息的文件,我想将该文件的版本存储在SQLite数据库文件中.

我怎样才能做到这一点?我的意思是,如何在SQLite中存储唯一(仅一个)数据?我不想通过为此创建表来存储信息,因为版本信息只是一个数字.

database sqlite

15
推荐指数
1
解决办法
1702
查看次数

"%s"%格式与"{0}".format()vs"?" 格式

在这篇关于SQLite的帖子中,aaronasterling告诉我

  • cmd = "attach \"%s\" as toMerge" % "b.db" : 是错的
  • cmd = 'attach "{0}" as toMerge'.format("b.db") : 是正确的
  • cmd = "attach ? as toMerge"; cursor.execute(cmd, ('b.db', )) :是对的

但是,我认为第一和第二是相同的.这三者有什么不同?

python string-formatting pysqlite

15
推荐指数
2
解决办法
2万
查看次数

ElementTree在Python2.6中的iter()等价物

我有这个代码与ElementTree适用于Python 2.7.我需要在"X/Y"节点下获取名为"A"的所有节点.

from xml.etree.ElementTree import ElementTree

verboseNode = topNode.find("X/Y")
nodes = list(verboseNode.iter("A"))
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用Python 2.6运行它时,我遇到了这个错误.

ionCalculateSkewConstraint.py", line 303, in getNodesWithAttribute
    nodes = list(startNode.iter(nodeName))
AttributeError: _ElementInterface instance has no attribute 'iter'
Run Code Online (Sandbox Code Playgroud)

看起来Python 2.6 ElementTree的节点没有iter().如何用Python 2.6实现iter()?

python xml elementtree python-2.6

15
推荐指数
2
解决办法
2万
查看次数

Windows 7中的主目录和.emacs文件

我在c:/emacs-23.3中安装了emacs 23.3.1.按照此页面中的提示,我更新了site-start.el以设置HOME环境变量.

(setenv "HOME" "c:/users/USER/emacs")
Run Code Online (Sandbox Code Playgroud)

我创建了c:/users/USER/.emacs(就像我在unix/mac中所做的那样)来编写使用slime的代码,但它似乎没有正确启动slime.

这是在Windows 7中设置emacs的正确方法吗?我在哪里放.emacs文件?

emacs installation windows-7

15
推荐指数
2
解决办法
2万
查看次数

当我们在Eclipse插件依赖项中有"Required Plug-ins"时,为什么我们需要`Imported Packages`?

在开发Eclipse应用程序时,MANIFEST.MF中的依赖项选项卡有两列.

一个是Required Plug-ins另一个是Imported Packages.

为什么我们需要Imported Packages时,我们有Required Plug-ins

评论认为"这个插件取决于没有明确地识别它们的原始插件",但是我不确定在什么情况下人们不想明确地识别它们的原始插件,它的优点是什么? ?

在此输入图像描述

添加

相关问题 - Eclipse软件包和插件之间有什么区别?

eclipse dependencies eclipse-pdt

15
推荐指数
1
解决办法
2617
查看次数

如何检查库是否是在Mac OS X上构建的32位/ 64位?

我在使用PyQt/SIP时遇到了一些麻烦.我想SIP被编译成64位,但Python在找到它时遇到了一些问题.

  File "qtdemo.py", line 46, in 
    import sip
ImportError: dlopen(/Library/Python/2.6/site-packages/sip.so, 2): no suitable image found.  Did find:
        /Library/Python/2.6/site-packages/sip.so: mach-o, but wrong architecture
  • 我怎么知道库(so/dylib)是32位还是64位?
  • 我怎么知道我的Python是32位还是64位?

python macos 64-bit python-sip

14
推荐指数
3
解决办法
1万
查看次数