Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a list of structs

Status
Not open for further replies.

sheila11

Programmer
Dec 27, 2000
251
US
Hi all,

I am a newbie, trying to create a list using STL. I need the list to be made up of structs. I can use a list made up of strings, ints, etc. But don't know the syntax for insert with a struct. What I have written is incomplete, but it's here:

#include <iostream>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

struct proc
{
int RTime;
int STime;
int ATime;
};


int main()
{
list <string> fruits;
fruits.insert(fruits.begin(),&quot;Apples&quot;);
//How to make list with structs as members?
}
Thanks,
Sheila
 
Sorry friends, I got this after a little thought. I had to create an instance of the struct and add that instance to the list.
Thanks,
Sheila
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top