Errors, bugs, questions - page 1417

 

A100:

virtual int Compare(const CObject *node,const int mode=0) const;


You are right. Short and clear, without any unnecessary words. I have posted a working code.

Files:
sort.mq5  3 kb
 
Stanislav Korotky:

As a result, inside this method typename correctly defines the type passed in, e.g. as int, but already inside the B constructor typename is equal to string.

The result of typename is always of type string, in other words typename can be represented conventionally as a function
string typename( X );
 
A100:
the result of typename is always of type string, in other words
That's not what I mean. typename returns a string containing the type name. Inside a templated class method, the string with the type is "int", and inside the constructor called from there, the string contains "string".
 
Stanislav Korotky:
That's not what I mean. typename returns a string with the type name. Inside the templated class method, the string with the type is "int", and inside the constructor called from there, the string contains "string".
class A { public:
template<typename T>
        A( T ) { Print( typename( T )); }
};
class B { public:
template<typename T>
        void f( T t ) { A a( t ); } //вызываем A::A(...)
};
void OnStart()
{
        B b;
        int i = 0;
        b.f( i );
}
Result: int
 

The compiler does not report an error if #endif is missing

#property library
#ifndef  MACRO
#define  MACRO

Preferably, it should, otherwise hard-to-find errors
 
A100:
Result: int.
Yes, this minimal example works as it should, but the more complex source code does not. Wrote it in SD.
 
CoderMQ4:

Guys, is this a Market bug or is it completely normal?


I haven't tried it, but it shouldn't work if it's tied to the hardware and not the operating system. It's like taking the hard drive off and putting it on a different motherboard with a different video. Will start looking for new drivers right away.

Or am I misunderstanding the virtual machine?

 

A call to a virtual function in an instance of a derived class results in a call to that function from the base class, not the derived class.

 
Ilya Malev:

A call to a virtual function in an instance of a derived class results in a call to that function from the base class, not the derived class.

This is always the case in the constructor. Why? -> google C++ (add the word constructor to the query string)
 
A100:
They always do in constructor. Why? -> google C++ (add the word constructor to the query string)

Thank you, I didn't know) It would be good to add it into MQL5 Reference, you know, where virtual functions and constructors are mentioned. It's not like that in all languages.

Reason: