obj2 = baseObj1;//Пока не грохнули объект - no problem
从你的角度来看,如何在建筑上做到这一点?
和这里一样。
class A {}; class B : public A {}; class C : public B {}; voidOnStart() { B *b = new B; delete b; B *c = b; b = new C; A *a = c; Print( a, ":", b, ":", c ); }
class A {}; class B : public A {}; voidOnStart() { B *b1 = new B; A *a = b1; delete b1; B *b2 = b1; b1 = new B; //уже другой объект a = b2; // Print( a, ":", b1, ":", b2 ); }
Condensed report! The following is a condensed report of the behaviour of the file when executed in a controlled environment. The actions and events described were either performed by the file itself or by any other process launched by the executed file or subjected to code injection by the executed file. Opened files C:\Documents and...
我遇到过(在我看来)对象指针的不正确行为。
它看起来像一个MQL错误。
你有这个错误。你如何想象将一个空的父代分配给一个子代?
它看起来像一个MQL错误。
你有这个错误。你如何想象将一个空的父代分配给一个子代?
就像一个非空的。在baseObj1中,有一个指向后裔类对象的 指针。如果你删除了delete(obj1),最后一行的赋值就不会引起任何问题--指针类型匹配。我认为,如果指针所指的对象被删除,赋值必须以同样的方式进行。而且必须没有 "无效指针访问 "的错误,因为没有试图访问一个被删除的对象。
这里是你的代码的这一部分。
显然,它在检查baseObj1所引用的对象的类型是否与指针obj2的类型相匹配。这里有两种可能性。
1) 指针本身可以是一个复杂的结构,包含对象的类型
2) 我们需要引用对象来找出它的类型。
这似乎是第2种情况,我们将不得不接受它。谢谢你的引导性问题 )
上周,卡巴斯基一直在终端机上大喊大叫,试图更新。
你的代码的这一部分
和这里一样。
class B : public A {};
class C : public B {};
void OnStart()
{
B *b = new B;
delete b;
B *c = b;
b = new C;
A *a = c;
Print( a, ":", b, ":", c );
}
就像这里。
class B : public A {};
void OnStart()
{
B *b1 = new B;
A *a = b1;
delete b1;
B *b2 = b1;
b1 = new B; //уже другой объект
a = b2; //
Print( a, ":", b1, ":", b2 );
}
上周,卡巴斯基一直在终端机上大喊大叫,试图更新。
包括卡巴斯基说的都清楚了。
https://www.virustotal.com/ru/file/2c3bf04666714cfac26e6e1c0fe355c6081554a0c2a15434849b0a5c241c95b0/analysis/1487685060/