You can use a std::vector
without initializing its size and it supports random access. To add to an empty std::vector
use push_back
std::vector<MyType> vec;
vec.push_back(MyType(10, 'a', "Hi"));
vec.push_back(MyType(20, 'b', "Hello"));
vec.push_back(MyType(30, 'c', "Bye"));
MyType t = vec[1];//20,'b', "Hello"...
Edit: This answer is for the question that was originally asked.
3
solved Why doesn’t this code for Sutherland-Hodgeman Line Clipping algorithm giving incorrect output?