I'm quite new to the standard template library, I'm trying to understand how to use them with my code. There may still be some logic errors in my code. However I am trying to sort out my syntax errors.
One big one is this:
type/value mismatch at argument 1 in template parameter list for template<class _Tp, class _Sequence> class std::queue'
expected a type, 'got T' //that too me is hilarious how its worded.
I know once I get this figured out I'll probably have alot more questions about whats going on, so please stick with me, and thanks.
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
template <int T>
class BruteForce {
private:
int currentItem, nextItem;
std::queue<T> q;
public:
void MakeQueue();
void GetPercepts();
int reflexAgent (int,int);
void DisplayInfo();
};
void BruteForce::MakeQueue() {
ifstream myfile;
myfile.open("sampleInput_reflex.txt");
while (!myfile.eof())
{
int i;
myfile >> i;
q.Push (i);
}
myfile.close();
}
void BruteForce::GetPercepts() {
if (q.size() > 1)
{
currentItem = q.front();
q.pop();
nextItem = q.front();
q.pop();
}
else if (q.size() > 0)
{
currentItem = q.front();
q.pop();
}
else
{
//the queue is empty.
}
}
int BruteForce::reflexAgent (int x, int y) {
int stop = 0;
int pickup = 1;
int advance = 2;
if (x || y == -1)
{return stop};
else if (x > y)
{return pickup};
else if (x > y)
{return advance};
}
void BruteForce::DisplayInfo() {
If (results == 0)
{
cout << "currentItem: " << currentItem << "\n"
<< "nextItem: " << nextItem << "\n"
<< "Action: Stop" << "\n\n";
}
else if (results == 1)
{
cout << "currentItem: " << currentItem << "\n"
<< "nextItem: " << nextItem << "\n"
<< "Action: Pickup" << "\n\n";
}
else if (results == 2)
{
cout << "currentItem: " << currentItem << "\n"
<< "nextItem: " << nextItem << "\n"
<< "Action: Advance" << "\n\n";
}
} //end displayInfo
Main()
{
//this looks something like this:
BruteForce <int> robot;
//I then call all functions using the robot object.
return 0;