-
Re: vector or list?
An example:
Code:
#include <vector>
class atom
{
public:
atom(){}
};
class molecule
{
std::vector<atom> theAtoms;
public:
molecule() {}
void setAtoms(int i);
int getNumberOfAtoms() const { return theAtoms.size(); }
};
void molecule::setAtoms(int i)
{
theAtoms.resize(i);
}
int main()
{
molecule m1;
m1.setAtoms(4); // 4 atoms
molecule m2;
m2.setAtoms(72); // 72 atoms
}
So exactly what is wrong with this? Isn't this what you're trying to acheive? Or maybe you can explain what your concerns are with the code that I posted (not what you initially posted).
Regards,
Paul McKenzie
-
Re: vector or list?
Hi Paul,
Thank you for your comments about the code that I used. Infact that was just to get a view what "laserlight" wanted to express. Actually, I never compiled the code to check if I was wrong. Hence main function was just "bad". Then using friend class, that was to make use of private member in molecule class. I forgot I was doing a blunder. Finally, memory leaks, I take care of those when I write code and test the application.
Anyway, thanks to all for help. And you wont believe, it was very quick. :))