How to take vector from class

Hello,

I have classes:

1
2
Polymer::Polymer()
    : _monomers(std::vector<Monomer>())



So I have created several Polymer objects , let's say p1, p2, p3. And now I want to compare the monomer vector of p1 with p2. What would be the proper way to do that, how to access the vector values of the class object?
I am succeeding only if I am creating get function:

const std::vector<T> & getVector() const
{
return vector;
}
usage:

const std::vector<T> &v = myClass.getVector();

But is this really a proper way?
I want to compare the monomer vector of p1 with p2.

Compare how?

Is it enough to get true, when vectors are identical?
No. Each monomer consists of another class which Cuboid
1
2
Monomer::Monomer()
    _geometry(Rectangle3D(1.0f, 1.0f, 1.0f))


which:
1
2
3
4
Rectangle3D::Rectangle3D()
        : _cuboid_length(1.0f)
        , _cuboid_width(1.0f)
        , _cuboid_height(1.0f)


So I have several polymer objects, and want to take each monomer of every of each and compare their parameters. Eventually I will write intersection function, but for now let's say I just want to know if polymer1.monomer1.length >polymer2.monomer1.length
I did mean, is the comparison something that Polymers do:
1
2
3
4
bool Polymer::compare( const Polymer& rhs )
{
  // code
}

or something that you do with Polymers:
1
2
3
4
5
6
T compare( const Polymer& lhs, const Polymer& rhs )
{
  const std::vector<Monomer> &lv = lhs.getVector();
  const std::vector<Monomer> &rv = rhs.getVector();
  // code
}

Last edited on
Thank you for your help. If I want to compare the monomers of the polymers I guess it is something that I do with Polymers/
Topic archived. No new replies allowed.