私は、オブジェクトの作成中に呼び出す必要があるパラメータ化されたコンストラクタで構成されるクラスを持っています。このクラスには、プライベートコピーコンストラクタも含まれています。次に、このクラスのparamterコンストラクタを呼び出す方法を示します。クラスへのポインタ参照を作成できると思います。しかし、参照を使用してパラメータコンストラクタを呼び出す方法は?コピーコンストラクタを含むクラスのパラメータコンストラクタをプライベートとして呼び出すにはどうすればよいですか?
私のプログラム:
#include<iostream>
#include<string>
using namespace std;
class ABase
{
protected:
ABase(string str) {
cout<<str<<endl;
cout<<"ABase Constructor"<<endl;
}
~ABase() {
cout<<"ABASE Destructor"<<endl;
}
private:
ABase(const ABase&);
const ABase& operator=(const ABase&);
};
int main(void)
{
ABase *ab;//---------How to call the parameter constructor using this??
return 0;
}
※私は 'const auto ab = std :: make_unique(foo);' :: unique_ptrを作成し、 'make_unique'が' new'を非表示にします)。 –