Is there any way that I can pass the second constructor argument along with the size of array, using smart pointer, in the code below?
class demo{
public:
int info;
demo():info(-99){} // default value
demo(int info): info(info){}
};
int main(){
// ok below code creates default constructor, totally fine, no problem
std::unique_ptr<demo> pt1 = std::make_unique<demo>();
// and this line creates argument constructor, totally fine, no problem
std::unique_ptr<demo> pt2 = std::make_unique<demo>(1800);
// But now, look at this below line
// it creates 5 object of demo class with default constructor
std::unique_ptr<demo[]> pt3 = std::make_unique<demo[]>(5);
// but I need here to pass second constructor argument, something like this : -
//std::unique_ptr<demo[]> pt3 = std::make_unique<demo[]>(5, 200);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire