Would this be legal and correct?
Random rnd(10); vector<Particle> dot(n, Particle(rnd));
I.e. will that create a vector of n-objects of class Particle, constructed with the constructor Particle(rnd)?
Also, would that be the appropriate way to pass an object of type Random to the Particle constructor? In the constructor, a member function of object rnd is called.
Will one copy of Random rnd be made for every object of Particle? That is not what I need, since the Random object is only used for generating a better pseudo-random number than rand(); Should I use pass-by-pointer or pass-by-reference instead? Wouldn't i have to manually create a copy of the pointed-to object in order to be able to call the member function? I feel I SHOULD know the answer to this, but right now I'm very confused.
The pseudo-random code i use is found here: Better Random Number Class - C++ - Source Code | DreamInCode.net
Also, is this a valid and correct way of accessing the elements in the vector?
dot.at(n).show(screen);
I will post more code if I have to, but I feel that should be sufficient for my questions. Besides, it's not finished nor neat as of now ;)


Sign In
Create Account


Back to top









