I m learning in c++ from the textbook but still confusing
C++ Programme:
using namespace std;
#include<iostream>
class A
{
public:
    A()
    {
        std::cout << "A\n";
    }
};
class B: public A
{
public:
    B()
    {
        std::cout << "B is derived class\n";
    }
};
int main()
{
    A * a=new A();  //valid 
    B * b=new B();  //valid
    A * aa=new B(); //valid    why?
    B * bb=new A(); //invalid  why?                                  run time error: invalid conversion from ‘A*’ to ‘B*’ [-fpermissive]
    return 0;
}
this line
A * a=new A();  //valid 
use because I want to access class a
and
this line
B * b=new B();  //valid 
use because I want to access class b
and
I m writing this line learning purpose I don't know but this is valid why??
A * aa=new B();  //valid
and
I m writing this line learning purpose I don't know but this is not valid why??
B * bb=new A(); //not valid
please explain the last two lines still confusion?
programme link: https://onlinegdb.com/Sy8xkt38L
 
     
    