空のベクターパラメータを渡す:私はこのクラスを使用している
class DogTrainer
{
public:
DogTrainer(int identity,const std::string& nom, const std::vector<Dog*> dogz) :
idD(identity),
name(nom),
trainees(dogz)
{ };
~DogTrainer();
private:
int idD;
string name;
std::vector<Dog*> trainees;
};
が、私は、新しいオブジェクトをインスタンス化するときに時々、私は「研修生」のパラメータを渡す必要はありませんので、私がしたいですこの
DogTrainer* Trainer=new DogTrainer(my_id, my_name);
は、したがって、私は私のDogTrainerコンストラクタ
DogTrainer(int identity,const std::string& nom, const std::vector<Dog*> dogz="") :
idD(identity),
name(nom),
trainees(dogz)
{ };
に変更しようとしましたが、それはdidnのを行うための可能性について持っています何か助けてください!
なぜ文字列リテラルですか?これはstd :: stringではありません。 – Pubby