草庐IT

private_extern

全部标签

C++ 私有(private)真的是私有(private)的吗?

我正在尝试C++中private访问说明符的有效性。如下:界面://class_A.hclassA{public:voidprintX();private:voidactualPrintX();intx;};实现://class_A.cppvoidA::printX(){actualPrintX();}voidA::actualPrintX(){std::cout我将它内置到静态库(.a/.lib)中。我们现在有一个class_A.h和classA.a(或classA.lib)对。我编辑了class_A.h并从中删除了private:。现在在另一个classTester.cpp中:#i

C++ 私有(private)真的是私有(private)的吗?

我正在尝试C++中private访问说明符的有效性。如下:界面://class_A.hclassA{public:voidprintX();private:voidactualPrintX();intx;};实现://class_A.cppvoidA::printX(){actualPrintX();}voidA::actualPrintX(){std::cout我将它内置到静态库(.a/.lib)中。我们现在有一个class_A.h和classA.a(或classA.lib)对。我编辑了class_A.h并从中删除了private:。现在在另一个classTester.cpp中:#i

C++ vector 问题 - 'LNK2001: unresolved external symbol private: static...'

在有人指责我不查看预先存在的问题之前,我已经查看并意识到它与声明有关,但我仍然无法让它工作(可能与我使用vector有关)。Manager.h:#include"Flight.h"#ifndefmanager_h#definemanager_hclassManager{staticvectorairports;staticvectorflights;public:staticvoidloadAirports();staticvoidloadFlights();staticAirportgetAirport(stringcode);staticvectorsplit(conststrin

C++ vector 问题 - 'LNK2001: unresolved external symbol private: static...'

在有人指责我不查看预先存在的问题之前,我已经查看并意识到它与声明有关,但我仍然无法让它工作(可能与我使用vector有关)。Manager.h:#include"Flight.h"#ifndefmanager_h#definemanager_hclassManager{staticvectorairports;staticvectorflights;public:staticvoidloadAirports();staticvoidloadFlights();staticAirportgetAirport(stringcode);staticvectorsplit(conststrin

c++ - 错误 LNK2019 : unresolved external symbol _main referenced in function ___tmainCRTStartup, 但这次不是 Windows/控制台问题!

所以,臭名昭著的错误又回来了。该项目提示它找不到main()方法(这就是错误的意思,对)。但是我确实有一个主项目,而且我的项目应该是一个控制台项目。它以前有效,所以我知道不是那样。此外,该项目有太多的类和文件,我无法将它们全部发布,所以我会根据您的要求发布您需要的任何类。这是VisualStudio2010上的C++、OpenGL和SDL游戏。这不是任何库的问题,因为它在突然莫名其妙地显示此链接器错误之前运行良好。编辑:main()方法:intmain(intargc,char**argv){glutInit(&argc,argv);glutInitDisplayMode(GLUT_D

c++ - 错误 LNK2019 : unresolved external symbol _main referenced in function ___tmainCRTStartup, 但这次不是 Windows/控制台问题!

所以,臭名昭著的错误又回来了。该项目提示它找不到main()方法(这就是错误的意思,对)。但是我确实有一个主项目,而且我的项目应该是一个控制台项目。它以前有效,所以我知道不是那样。此外,该项目有太多的类和文件,我无法将它们全部发布,所以我会根据您的要求发布您需要的任何类。这是VisualStudio2010上的C++、OpenGL和SDL游戏。这不是任何库的问题,因为它在突然莫名其妙地显示此链接器错误之前运行良好。编辑:main()方法:intmain(intargc,char**argv){glutInit(&argc,argv);glutInitDisplayMode(GLUT_D

c++ - 公共(public)算子新建,私有(private)算子删除 : getting C2248 "can not access private member" when using new

一个类有重载的操作符new和delete。new是公开的,delete是私有(private)的。在构造该类的实例时,出现以下错误:pFoo=newFoo(bar)example.cpp(1):错误C2248:'Foo:operatordelete':无法访问在类'Foo'中声明的私有(private)成员但是这里没有调用delete,那么编译器扭曲的头脑中发生了什么?:)错误的原因是什么?是否可以在不借助成员CreateInstance函数的情况下解决问题? 最佳答案 当您执行newFoo()时,会发生两件事:首先调用operat

c++ - 公共(public)算子新建,私有(private)算子删除 : getting C2248 "can not access private member" when using new

一个类有重载的操作符new和delete。new是公开的,delete是私有(private)的。在构造该类的实例时,出现以下错误:pFoo=newFoo(bar)example.cpp(1):错误C2248:'Foo:operatordelete':无法访问在类'Foo'中声明的私有(private)成员但是这里没有调用delete,那么编译器扭曲的头脑中发生了什么?:)错误的原因是什么?是否可以在不借助成员CreateInstance函数的情况下解决问题? 最佳答案 当您执行newFoo()时,会发生两件事:首先调用operat

c++ - 私有(private)成员的常量访问器之间的比较

这个问题的主要部分是关于为类内的私有(private)数据成员创建公共(public)只读访问器的正确且计算效率最高的方法。具体来说,利用consttype&引用来访问变量,例如:classMyClassReference{private:intmyPrivateInteger;public:constint&myIntegerAccessor;//AssignmyPrivateIntegertotheconstantaccessor.MyClassReference():myIntegerAccessor(myPrivateInteger){}};然而,目前解决这个问题的既定方法是利

c++ - 私有(private)成员的常量访问器之间的比较

这个问题的主要部分是关于为类内的私有(private)数据成员创建公共(public)只读访问器的正确且计算效率最高的方法。具体来说,利用consttype&引用来访问变量,例如:classMyClassReference{private:intmyPrivateInteger;public:constint&myIntegerAccessor;//AssignmyPrivateIntegertotheconstantaccessor.MyClassReference():myIntegerAccessor(myPrivateInteger){}};然而,目前解决这个问题的既定方法是利