D
deancoo
Hello all,
I'm new to the C++ STL, and am trying to wrap my head around why the
following piece of code doesn't compile. What am I doing wrong? Thanks for
any help.
d
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
class int_container {
public:
int int_value;
};
int main(int argc, char *argv[])
{
vector<int_container*> my_containers;
for (int i=1; i<=5; i++) {
my_containers.push_back(new int_container);
};
vector<int_container*>::iterator j;
for (j=my_containers.begin(); j!=my_containers.end(); j++) {
(*j).int_value = 0; // this is the line the compiler points to as
culprit
};
/* */
system("PAUSE");
return EXIT_SUCCESS;
}
I'm new to the C++ STL, and am trying to wrap my head around why the
following piece of code doesn't compile. What am I doing wrong? Thanks for
any help.
d
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;
class int_container {
public:
int int_value;
};
int main(int argc, char *argv[])
{
vector<int_container*> my_containers;
for (int i=1; i<=5; i++) {
my_containers.push_back(new int_container);
};
vector<int_container*>::iterator j;
for (j=my_containers.begin(); j!=my_containers.end(); j++) {
(*j).int_value = 0; // this is the line the compiler points to as
culprit
};
/* */
system("PAUSE");
return EXIT_SUCCESS;
}