Hello,

Can anyone explain what's wrong with below code:
Code:
#include <iostream>
#include <vector>


using namespace std;


class A
{
public:
    virtual int get() = 0;
};


class B : public A
{
public:
    int get() { return 0; };
};


int main()
{
    std::vector<A> v;


    B b;
    v.push_back(b);
};
And throws this error:
Code:
/usr/bin/g++ -pthread --std=c++17 -fdiagnostics-color=always -g /home/test/*.cpp -o /home/test/main
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from /home/test/main.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = A; _Args = {const A&}; _Tp = A]’:
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = A; _Args = {const A&}; _Tp = A; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<A>]’
/usr/include/c++/9/bits/stl_vector.h:1189:30:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = A; _Alloc = std::allocator<A>; std::vector<_Tp, _Alloc>::value_type = A]’
/home/test/main.cpp:24:18:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: invalid new-expression of abstract class type ‘A’
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/test/main.cpp:7:7: note:   because the following virtual functions are pure within ‘A’:
    7 | class A
      |       ^
/home/test/main.cpp:10:17: note:   ‘virtual int A::get()’
   10 |     virtual int get() = 0;
      |                 ^~~


Build finished with error(s).