记忆存放在哪里?
I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...
记忆存放在哪里?
取决于汇编者。
在VC++,在任何成员数据之前,在目标分配开始时储存的表点。 (你的班级至少有一个虚拟成员职能)
如果您的班级从其他班级乘车,也可能有多个变点。
www.un.org/Depts/DGACM/index_spanish.htm 舱面本身在你地址的某个地方固定分配。
然后,物体布局(例如C):
A s VTable ptr
A s member variables.
B s Vtable ptr
B s member variables.
C s member variables.
页: 1
class A {
virtual Ax() {}
int a, b;
};
class B {
virtual Bx() {}
int c, d;
};
class C : public A, public B {
int foo, bar;
};
稳定? 什么是可信的? C++标准没有提及一个表态。 每个汇编者都可以以类似的方式履行虚拟职能。 这包括在它喜欢的地方放置table。
通常在标首处(Imperfect C++,Backyard Hotrotter C++),但该标准没有保证。 在标准中,使用吸收器和表象是保证的。
如果你真的需要知道什么地方,那么,通常会使用像COM、XPCOM、UN等这样的东西,这些东西基本上由一个固定地点来实施,那里像一个排位者一样,并且为使用它们规定了方法。
包括虚拟功能的每一个例子都有虚拟功能点,显示虚拟功能表(vbtl),我们只能通过实例确定标识。 或者你可以将斜线改为欧阵档案的象征,或许可以找到答案。 我希望,以下例子能够给你抹去。
#include <iostream>
#include <stdio.h>
typedef void (*fun_pointer)(void);
using namespace std;
class Test
{
public:
Test()
{
cout<<"Test()."<<endl;
}
virtual void print()
{
cout<<"Test::Virtual void print()."<<endl;
}
virtual void print2()
{
cout<<"Test::virtual void print2()."<<endl;
}
};
class TestDrived:public Test
{
public:
TestDrived()
{
cout<<"TestDrived()."<<endl;
}
virtual void print()
{
cout<<"TestDrived::virtual void print()."<<endl;
}
virtual void print2()
{
cout<<"TestDrived::virtual void print2()."<<endl;
}
void GetVtblAddress()
{
cout<<"vtbl address:"<<(int*)this<<endl;
}
void GetFirstVtblFunctionAddress()
{
cout<<"First vbtl function address:"<<(int*)*(int*)this+0 << endl;
}
void GetSecondVtblFunctionAddress()
{
cout<<"Second vbtl function address:"<<(int*)*(int*)this+1 << endl;
}
void CallFirstVtblFunction()
{
fun = (fun_pointer)* ( (int*) *(int*)this+0 );
cout<<"CallFirstVbtlFunction:"<<endl;
fun();
}
void CallSecondVtblFunction()
{
fun = (fun_pointer)* ( (int*) *(int*)this+1 );
cout<<"CallSecondVbtlFunction:"<<endl;
fun();
}
private:
fun_pointer fun;
};
int main()
{
cout<<"sizeof(int):"<<sizeof(int)<<"sizeof(int*)"<<sizeof(int*)<<endl;
fun_pointer fun = NULL;
TestDrived a;
a.GetVtblAddress();
a.GetFirstVtblFunctionAddress();
a.GetSecondVtblFunctionAddress();
a.CallFirstVtblFunction();
a.CallSecondVtblFunction();
return 0;
}
缩略语和缩略语储存在数据部分......
表象是一系列职能点。
缩略语和变式正在汇编时制作,在运行时间获得记忆,而且正表条目是虚拟功能地址。
包含虚拟功能的每类物品都将有额外的点子,标明虚拟表格为虚拟点。
每当我们使用物体称为虚拟功能时,先是校正器将适时从速读到功能,最后将称为功能。
I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...
I have been searching for sample code creating iterator for my own container, but I haven t really found a good example. I know this been asked before (Creating my own Iterators) but didn t see any ...
Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...
I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?