类中有对象成员的复制解决思路

类中有对象成员的复制
#include<iostream>
using namespace std;
 
class A
{
public:
    A(){m_a= 10;cout<<"A()"<<endl;}
void seta(){m_a = 20;}
int geta(){return m_a;}
    A(const A&){cout<<"A(const A&)"<<endl;}
  
    int m_a;
};
 
class B
{
public:
    B(){m_b = 10; cout<<"B()"<<endl;}
void setb(){m_b = 20;}
int getb(){return m_b;}
B(const B&b){cout<<"B(const B&)"<<endl;}//无法在初始化列表中调用对象a的复制构造函数
    
    int m_b;
    A a;
};
  
int main()
{
    
    B b;
b.a.seta();
b.setb();
       cout<<"copy constructor"<<endl;
      B b2 = b;
cout<<b2.a.geta()<<endl<<b2.getb()<<endl;


    
}


B(const B&b){cout<<"B(const B&)"<<endl;}//无法在初始化列表中调用对象a的复制构造函数
那怎么复制类B中的对象成员a呢?
------解决方案--------------------

B(const B&b):a(b.a)
{cout<<"B(const B&)"<<endl;}