I have the following code:
#include
#include
class Test
{
public:
int first;
int second;
Test(int a, int b)
{
first = a;
second = b;
}
};
int main(int argc, char* argv[])
{
std::vector mydata({ Test(4, 8), Test(5, 3), Test(12, 7), Test(8, 9) });
for (auto const&y : mydata)
{
std::cout << y.first << " / " << y.second << std::endl;
}
//need to free vector here or sth?
return 0;
}
I use class constructor to initialize vector.
Is the code above good or can cause errors?
Should I free the vector at the end of the program?
No comments:
Post a Comment