1.子类可以用父类来初始化吗?
2.unique_ptr可以赋值给另外一个unique_ptr吗?
3.虚函数的实际过程是啥?
#include<bits/stdc++.h>
using namespace std;
class node
{
public:
node() {}
virtual ~node() {}
virtual void sum()
{
cout<<"A"<<endl;
}
};
class Node:public node
{
public:
Node() {}
virtual ~Node() {}
void sum()
{
cout<<"B"<<endl;
}
};
int main()
{
node *A=new Node;
A->sum();//不报错
// Node *A=new node;
// A->sum();//报错
std::unique_ptr<int> sp1;
//std::unique_ptr<int> sp2=sp1;//报错
std::unique_ptr<int> sp2=move(sp1);//不报错
}