What is a possible workaround for object slicing in c++?

后端 未结 3 1992
情书的邮戳
情书的邮戳 2020-12-06 03:12

This is the code:

#include 
#include 
#include 
using namespace std;
class A {
public:
  virtual const string f()         


        
3条回答
  •  星月不相逢
    2020-12-06 03:20

    You need to store pointers. If these refer to dynamically allocated objects, use smart pointers.

提交回复
热议问题