I have a custom vector
class which have the following functions, push
, pop
, print
in which the print
function will print out all elements in the vector. The private attributes of the vector are m_current
(Current iterator), m_size
(size of vector) and Datatype m_data
(templated).
Now I have another class called Data which have the following attributes, m_date
, m_time
.
I declared 2 vectors with this.
vector<Data> vect1(10);
vector<Data> vect2(10);
And then, I declare another vector to house these vectors.
vector<vector<Data>> vect3(10);
vect3.push(vect1);
vect3.push(vect2);
My question is, just how do i access the m_time
of vect1
through vect3
?
Assuming your vector class implements operator[]
, which it should, it's as simple as this:
vect3[0][0].m_time
If the element accessor has an other name, such as get_element(int id)
, it would be
vect3.get_element(0).get_element(0).m_time
If there is no element accessor function, then congratulations, you have created Write-only memory.