Errors, bugs, questions - page 1737

 
Or even simpler situation.
class A
{
  const int a;
  
  A() : a(this.f()) {}
  
  int f() { return(0); }
};
Why does this compile at all? this is used even BEFORE the constructor body is called.
 
fxsaber:
Or even simpler situation.
class A
{
  const int a;
  
  A() : a(this.f()) {}
  
  int f() { return(0); }
};
Why does this compile at all? this is used even BEFORE the constructor body is called.
Why don't you include an initialization list in the body? Figuratively speaking, a class object (including this) is initialized at the ':' sign
 

Ilyas:
Почему список инициализации Вы не включаете в тело?

Because const int a; You can't do it otherwise, right?

Figuratively speaking, an object of a class (including this one) is initialized on the ':' sign

Got it.
 
Dear moderators, if a product (indicator) that is available for a fee in the Market can be made free of charge, is it possible to openly display and discuss its work on the forum without fear of being banned? Or, what is the best way to proceed?
 
Yousufkhodja Sultonov:
Dear moderators, if a product (indicator) that is available for a fee in the Market can be made free of charge, is it possible to openly display and discuss its work on the forum without fear of being banned? Or, what should I do?
Any advertising is prohibited, you will be banned immediately. it is better not to take the risk.
 

Compilation error

class A {};
class B {
public:
        static int k;
};
int B::k = 0;
#define MACRO( classC, classB )      \
class classC : public classB {       \
public:                              \
        classC( A *aa ) : a( aa ) {} \ //(1)
        A *a;                        \ //(2)
        int f( int i );              \
};                                   \
int classC::f( int i )               \
{                                    \
                classB::k = i;       \ //error: '::' - open parenthesis expected
        int j = classB::k;           \ //нормально
        return j;                    \
}
MACRO( C, B )
And if you delete lines (1) and (2), for example, there is no error. Why did they interfere!?
 
 
Vladislav Andruschenko:
any advertising is banned, banning is immediate. You don't want to take any chances.
It's better to have a blog thread, you can do anything there.
 
Alexey Volchanskiy:
It's better to have a blog thread, you can do everything there.
))))))) and promote your blog ))))))))
 
Hi all. There's this weird indentation at the bottom and I can't get it out of the way.
Files:
k1amn19a2h.png  37 kb