vector within struct: syntax confusion

Hi all, my first post happens to be a question:

What is the proper syntax to use a vector within a struct? Here's an example of what I want to do:

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

using namespace std;

struct myStructure {
  float number;
  vector<string> nameList();
};

int main(){
  myStructure data;
  data.float=3.1415;
  data.nameList.push_back('goatgoat');  //I'm pretty sure this is correct

  clearStructureData(data);
}

void clearStructureData(data){  //I want this funct to wipe 'data' clean
  data.float=0;
  data.nameList.clear(); //<-- ERROR: insufficient contextual info to determine type
}



There must be some way to clear that vector. Any ideas why this doesn't work?

-goatgoat
Remove the parentheses on line 9, otherwise you are declaring a function that returns a vector. The rest of your code is fine.
Zhuge,

You are the king. It works now.

I suppose I did that because I'm used to arrays (I was almost considering using an array instead, which would have been much much more work through the rest of my program).

Thanks a million!
Topic archived. No new replies allowed.