Accessing data in structs

I haven't coded in awhile, and apparently I'm REALLY rusty because I seem to have forgotten something about structs. I created some simple code to refresh my memory:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>

using namespace std;

struct p
{
	int b;
};

int main(int argc, char *argv[])
{
        vector<p> plist;
	for (int i = 0; i < 3; i++)
	{
		p test;
		p.b = i;
                plist.push_back(test);
	}
}


I thought you could access data members of a struct simply by using the dot operator (p.b = i), but its giving me a compilation error at that line (17). Clearly I've forgotten something very basic, can anyone help out?
Last edited on
test.b = i;
Uuuuugh, I'm such an idiot. Thank you.
Topic archived. No new replies allowed.