假设我有这门课:
class Shape
{
public:
int value;
Shape(int v) : value(v) {};
void draw()
{
cout << "Drawn the element with id: " << value << endl;
}
};
Run Code Online (Sandbox Code Playgroud)
和以下代码(有效)
Shape *myShapeObject = new Shape(22);
void (Shape::*drawpntr)();
drawpntr = &Shape::draw;
(myShapeObject ->*drawpntr)();
Run Code Online (Sandbox Code Playgroud)
我有一个drawpntr函数指针指向类Shape的void-returns 0-arguments函数成员.
首先我想问一下:
drawpntr = &Shape::draw;
Run Code Online (Sandbox Code Playgroud)
该函数是一个成员函数,这里没有对象.. drawpntr接收什么地址?这个班级甚至不应该存在
我同意这条线
(myShapeObject->*drawpntr)();
Run Code Online (Sandbox Code Playgroud)
因为我明白我不能将函数指针解引用成员函数(没有对象 - >没有函数),但实际存储在drawpntr中的地址是什么?这个时候没有任何对象
drawpntr = &Shape::draw;
Run Code Online (Sandbox Code Playgroud)
line被调用..并且该类不应该作为实体存在
我知道C++中的::运算符是作用域解析,但是在类中调用函数的目的是什么呢?
class MyClass
{
int myFunc(int argument)
{
// do some stuff
return (::myFunc(another_argument));
}
}
Run Code Online (Sandbox Code Playgroud)
有实际的原因吗?这个是"这个"吗?
我看到了这个模板声明:
template<typename C, typename R, typename P1, typename P2> struct mystruct<R(C::*)(P1,P2)> { ... };
Run Code Online (Sandbox Code Playgroud)
我知道C ::*的意思是"指向C成员的指针",但我无法理解R(C ::*)(P1,P2)的作用
在Linux中,我们可以从关联的驱动程序文件对象读取/写入,并且这些函数调用将由驱动程序读/写函数承载.在Windows中它是一样的吗?
我们是否将文件与驱动程序关联并通过读/写此文件来访问驱动程序函数?
(我一直在Linux下编写驱动程序,现在我正试图理解"Windows方式"来实现它.)
我看到在Windows上,函数EnumProcessModules返回为指定进程加载的一些模块(其中一些应该是系统dll,如guard32.dll,version.dll等).
我的问题是:这些模块是否映射到流程的虚拟空间?我可以从主应用程序代码跳转到其中一个模块(当然知道地址)的指令吗?
我想了解SSE/SSE2如何工作的更多信息:我知道SSE/SSE2使用mmx寄存器,大小为128位(16字节),通常这些寄存器有4个浮点单元,我可以通过打包存储我的浮点数.在得到结果之前,我应该"打开它们".
我的问题是:因为我是菜鸟,为什么要将这些值打包到xmm寄存器中,为什么要解压它们呢?这有什么好处?
我知道,如果我没有释放分配的内存删除/免费我最终会有内存泄漏.我的问题是:如果我的程序被终止,操作系统是否会为我释放内存,即使我没有?
如果仅对32个低位进行操作,ADD EAX和EBX是否会将EAX的32个高位置零?
那ADD RAX,EBX又如何呢?可能吗?如果是的话,是否保留了RAX的32个高阶位?
这段代码没有返回任何东西,我是以错误的方式逃避w字符吗?
http://liveworkspace.org/code/3bRWOJ $ 38
#include <iostream>
#include <regex>
using namespace std;
int main()
{
const char *reg_esp = "\w"; // List of separator characters.
// this can be done using raw string literals:
// const char *reg_esp = R"([ ,.\t\n;:])";
std::regex rgx(reg_esp); // 'regex' is an instance of the template class
// 'basic_regex' with argument of type 'char'.
std::cmatch match; // 'cmatch' is an instance of the template class
// 'match_results' with argument of type 'const char *'.
const char …Run Code Online (Sandbox Code Playgroud)