Is there a way we can create array objects and initialise them using the parametric constructor. Something like below
class myvector
{
public:
myvector();
~myvector();
myvector(int s) : elem ( new double[s] ),sz (s) {}
private:
double *elem;
int sz;
};
int main(int argc, const char * argv[]) {
myvector abc[10](10); //is there any other way to achieve this, create 10 objects and sent 10 as parameter in one-liner.
}
Aucun commentaire:
Enregistrer un commentaire