F
F
Fango2020-12-07 18:17:24
C++ / C#
Fango, 2020-12-07 18:17:24

Who can write a program according to the mechanism of the compiler?

class A {
  protected:
    int i = 1;
  public:
    void func() { cout << " " << " "; }
  };
  class B :public A {
  public:
    B() { i++; }
    void func1() { cout << " " << i << " "; }
  };
  int main() {
    A a;
    A *p;
    p = &a;
    B b;
    p->func();
    p = &b; 
    p->func();
    ((B*)p)->func1();
    return 0;
  }


Why does the compiler jump from A a to p = &a; ignoring A*p and so on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-12-07
@Fango

1. It's called a "debugger".
2. It can stop execution on any actions.
3. And the line with the variable declaration does not perform any action.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question