Errors, bugs, questions - page 1119

 

Compilation error: the compiler thinks I'm passing a pointer by reference

class A {
};

void f1( A*  a ) {}
void f2( int a ) {}

void OnStart()
{
        A* const a1 = new A();
        f1( a1 ); // ошибка компиляции: constant variable cannot be as reference
        const int a2 = 1;
        f2( a2 ); //все нормально
}

If I write f1( A* const a ), everything compiles well, but I don't write f2( const int a ) and in case of f2( int a ) the compiler gets it right


по сути
f1( A*  a ) отличается от f1( A* const  a )
тем же, чем
f2( int a ) отличается от f2( const int a )
then there should be an error in f2( a2 ) too
 
Lone_Irbis:

I don't want to post the whole code and .set to it here, but I can send it somewhere.

Thank you! Let's try to reproduce it. The code can be sent to servicedesk (after all checks it will be guaranteed to be deleted).
 

Can't delete a const A* pointer

class A {
};

void OnStart()
{
        const A *a = new A;
        delete( a ); //ошибка компиляции: constant cannot be modified
}

At first sight it seems logical - delete calls destructor ~A(), and it cannot be const (***)

BUT then it would be impossible in principle to delete the object in the following example

void f()
{
    const A a;
}

because the destructor, which cannot be const, is still called when exiting f() and therefore the (***) doctrine does not work

Besides, the C++ compiler does not prevent delete( a ), even if the argument is declared as const A * (the destructor cannot be declared as const, because it is called for any, including non-const, objects)

 
no longer counts for posts(
 
GriFFon4ik:
no longer counts for posts(
Yes, no longer ...
 
GriFFon4ik:
no longer counts for posts(
Whatever.
 
barabashkakvn:
Oh well.
sad :-(
 

I checked the post, it didn't increase. Maybe there's some clever improved formula...

Forum on trading, automated trading systems and testing trading strategies

Interesting & Humorous

newdigital, 2014.04.09 14:23

Should be banned from thinking - it's offensive!

The lines are knitted into a poem,
The sea licks the dry land.
Children poop in the potty,
♪ Adults poop in their souls ♪

Whatever happened to the rating.
 
newdigital:

I checked my post here - it hasn't increased. Maybe there's some clever improved formula...

Whatever happened to the rating.
It's working) but no(
 
Stopped counting rating for forum posts (
Errors , website mql5.com , closed , initiative: 2014.04.09 14:07 , # 993171

Stopped counting rating for forum posts (



Support group2014.04.09 15:27
What made you think that?
GriFFon4ik2014.04.09 17:38
Well it used to be written comment, rating immediately +1, but now there is no "+1 immediately"
Support group2014.04.09 17:38

Now the ratings will be assigned periodically, with a delay