What's the output / behavior of the following code?

All QuestionsCategory: Cpp LanguageWhat's the output / behavior of the following code?
Anonymous asked 3 years ago

class A{
   int x;
   public:
   A(int p):x(p)  {  }
   virtual void f1()  const {  }
   };
 
class B: public A{
    int y;
    public:
    B(int p, int q) : x(p), y(q)  {  }
    virtual void f1()   const {  }
    virtual void f3()   const {  }
};
 
int main() {
   A *ptr = new B();
   ptr -> f3();
   return 0;
}
 
Options:
 

  1. runtime error
  2. compile-time error
  3. linker error
  4. No error, f3 will be called from class 8