English 中文(简体)
如果被宣布为A级,哪里将留级? [闭门]
原标题:Where the a class instance will be located on memory if it is declared as A a? [closed]

If declare an instance of class A : "A a;" which kind of memory type will it be created on? any other type of memory type?

My solution:

It depends on where it is declared. If it is a global variable, and outside any class and functions, it is on heap. If it in a class or function, it is on stack. If is in a namespace, it is on heap .

权利?

问题回答

你们的问题假设,只有两个答案是“st”和“肥皂”。

所有在职能或类别/单位之外宣布的变量都生活在全球记忆<>>。 因此,它们通常称为“全球化”。 这一记忆是通过装上可执行类别生成的,施工人在<代码>main上填满(代号在<代码><>main/code>之后打电话给行人)。

如果你宣布某一职能范围内的一个变数,那么它就处于停滞状态。 进入“跃进”的唯一途径是,如果你以<条码>(新<>/代码>)明确分配,或者如果它是自己分配的某些其他物体的成员。

班级/单位的成员在申报其变数的地方生活。

如果它发挥地方作用,它就走了脚。 如果它具有全球或静态,它就属于可执行的数据部分(AAKA“全球记忆”。) 如果在另一类人中作出声明,则可以根据如何分配班级。

姓名空间不影响任何东西。 它只是汇编者。

EDIT :班级。

如果某一案件被宣布为A a;,则此项声明将属于某一类别,如:

class B
{
    A a;
};

接着,<代码>a的存储位置由<代码>B的附加说明的指定方式决定。 例如,在<代码>B b;中,适用相同的规则——包括笔记或全球记忆。 如果是,

B*b = 新的B(a)

但是,随后,您的<代码>A与<代码>其他部分同时在座。 B。





相关问题
Undefined reference

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 ...

C++ Equivalent of Tidy

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 ...

Template Classes in C++ ... a required skill set?

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?

Print possible strings created from a Number

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->...

typedef ing STL wstring

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, ...

C# Marshal / Pinvoke CBitmap?

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 ...

Window iconification status via Xlib

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?