Errors, bugs, questions - page 1816

 
Mist13:

I've encountered (in my opinion) incorrect behaviour of object pointers.

It looks like an MQL error.

You have the error. How do you imagine assigning an empty parent to a descendant?

 
fxsaber:

It looks like an MQL error.

You have the error. How do you imagine assigning an empty parent to a descendant?

Exactly the same as a non-empty one. The baseObj1 contains a pointer to the object of the descendant class. If you remove delete(obj1), the assignment in the last line doesn't cause any problems - the pointer types match. I think the assignment must go the same way if the object the pointer refers to is deleted. And there should certainly be no "Invalid pointer access" error - there is no attempt to access a deleted object.
 
Mist13:
Exactly the same as non-empty. In baseObj1 there is a pointer to an object of descendant class. If you remove delete(obj1), the assignment in the last line doesn't cause any problems - the pointer types match. I think the assignment must go the same way if the object the pointer refers to is deleted. And there must be no "Invalid pointer access" error for there is no attempt to access a deleted object.
This part of your code
obj2 = baseObj1;//Пока не грохнули объект - no problem
how, from your point of view, can it be implemented architecturally?
 
       obj2 = dynamic_cast<B *>( baseObj1 );//нормально
Such casting, if at all possible, is only possible if the base object exists.
 
And how do I upload files to the market after the update?
 
fxsaber:
Here is this part of your code.
obj2 = baseObj1;//Пока не грохнули объект - no problem
How, from your point of view, can it be done architecturally?

Apparently, it's checking if the type of object referenced by baseObj1 matches the type of pointer obj2. There are two possibilities here:

1) The pointer itself can be a complex structure that contains the type of the object

2) We need to refer to the object to find out its type.

This seems to be case #2, and we'll have to live with it. Thanks for the leading questions )

 

Kaspersky has been yelling at the terminal trying to update for the last week.

 
fxsaber:
This part of your code
obj2 = baseObj1;//Пока не грохнули объект - no problem
how, from your point of view, can it be done architecturally?

Same as here.

class A {};
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 );
}
 
A100:
Just like here.
class A {};
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 );
}
Where?
b1 = a;
 
vladavd:

Kaspersky has been yelling at the terminal trying to update for the last week.

don't panic!)

all clear, build 1545. including kaspersky says all clear
https://www.virustotal.com/ru/file/2c3bf04666714cfac26e6e1c0fe355c6081554a0c2a15434849b0a5c241c95b0/analysis/1487685060/








Antivirus scan for 2c3bf04666714cfac26e6e1c0fe355c6081554a0c2a15434849b0a5c241c95b0 at 2017-02-21 13:51:00 UTC - VirusTotal
  • www.virustotal.com
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...