#include<iostream>
using namespace std;
int main()
{
int *p,*c;
p=(int*)10;
c=(int*)20;
cout<<(int)p<<(int)c;
}
有些人问我,“上述法典有什么错误?”,我怎么说。 有些人请帮助我。
#include<iostream>
using namespace std;
int main()
{
int *p,*c;
p=(int*)10;
c=(int*)20;
cout<<(int)p<<(int)c;
}
有些人问我,“上述法典有什么错误?”,我怎么说。 有些人请帮助我。
有些人希望从C++标准中引用(如果评论格式受到严格限制,则在答复中说明这一点),这里是1999年两种:
5.2.10/3
由<代码>reinterpret_cast绘制的地图界定了实施情况。
5.2.10/5
A value of integral type or enumeration type can be explicitly converted to a pointer. A pointer converted to an integer of sufficient size (if ant such exists on the implementation) and back to the same pointer type will have its original value; mappings between pointers and integers are otherwise implementation-defined.
我认为,没有任何人要求,这种执行界定的制图必须为所有投入提供有效代表。 否则,在建立有地址登记册的架构方面,如果执行的话,就会非常容易陷入困境。
p = (int*)10;
如果绘图当时不提供有效代表(即点人的有效代表可能取决于时间)。 例如,delete
可能使被删除的点名的表述无效。
根据C++标准,<编码>int和点数据类型不必有相同数目的比照,这是一件事——这意味着你可能失去准确性。
此外,将<代码>int投到>int
上,然后又重新贴上sil。 为什么不要把它作为<代码>int?
我实际上在did试图将这一项目列入议程,并做的是罚款,但事故可能比良好设计多。
假设我对应该做些什么是正确的,那么它就应当这样看待:
int main()
{
int *p, *c;
// Something that creates whatever p and c point to goes here, a trivial example would be.
int pValue, cValue;
p = &pValue;
c = &cValue;
// The & operator retrieves the memory address of pValue and cValue.
*p = 10;
*c = 20;
cout << *p << *c;
}
为了给点人参照的变量分配或检索价值,您需要rel=“nofollow noreferer”>。 它。
你们的法典正在把10个点推到暗中(即实际住处的记忆地址)。
页: 1
你需要的一些平台的问题
p = (int*) (long) 10;
See GLIB documentation on type transformation Macs 。
对于那些可能无法为这种表达方式找到用途的人,有可能将数据放在点值回报功能中。 你们可以找到真正的世界实例,在这种情况下,最好利用这一主轴,而不是在大跌上分配新的愤怒,然后回头来——表现不佳、记忆破碎。
如果你试图在这些地址读取数据,你将价值(10和20)重新分配给显然是一个潜在问题的点。 给愤怒的指点也确实是令人怀疑的。 你的主要职能没有回报说明。 这只是几个方面。
与此相比,情况有:
int *p,*c;
p=(int*)10;
c=(int*)20;
这并不十分故意。
而且,我相信,整个方案只会失事。
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?