outputting from a queue

I can access the values directly, but am having trouble accessing the data via the queue, just for a simple output, what do you guys reckon?

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  #include <iostream>
#include <string>
#include <iomanip>
#include <queue>

using namespace std;
char g;

struct unit // structer the name prod
{
string name; // set as a string to enter letters and numbers
float timetobuild; // float this item
}soldier,dog,flamer,sniper;

queue<unit> troops;

void setvalue(){
soldier.name = "soldier";
soldier.timetobuild = 1;
dog.name ="war dog";
dog.timetobuild = 2;
flamer.name = "flamer";
flamer.timetobuild = 4;
sniper.name ="sniper";
sniper.timetobuild = 3;
}

int main()
{
	setvalue();

troops.push(soldier);
troops.push(dog);
troops.push(flamer);
troops.push(sniper);


cout << soldier.name << " has this minuties to build: " << soldier.timetobuild << "\n";
cout << dog.name << " has this minuties to build: " << dog.timetobuild << "\n";
cout << flamer.name << " has this minuties to build: " << flamer.timetobuild << "\n";
cout << sniper.name << " has this minuties to build: " << sniper.timetobuild << "\n";

cin>> g;
}
Topic archived. No new replies allowed.