Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I am trying to compile my program and it tells this: error: class std:: queue < std vector basic_string >> has no members named

So I am trying to compile my program and it tells this:

error: class std:: queue < std vector basic_string >> has no members named Tokenize, GetTokens. What am I doing wrong?

those two functions are on my other class and they are public and I did include the header file on both this driver and my other class

this driver reads in a .txt file and sends it to my tokenize function which accepts a string parameter tokenizes it and GetTokens is a vector of strings which gets the tokenized tokens

#include "prog2_1.hpp"//header file #include #include #include #include using namespace std; int main(int argc, char *argv[]){ int j = 0; ifstream file(argv[1]); while(!file.eof()){ string a; getline(file,a); queue > token; token.Tokenize(a);//error cout << "error on line "<< j << ": "; while(!token.GetTokens.empty()){error cout << token.GetTokens() << " "; } j++; } }

#include "prog2_1.hpp"//header file

#include #include #include #include Tokenizer::Tokenizer(){ this->data = new queue >(); } Tokenizer::~Tokenizer(){ delete this->data; } void Tokenizer::Tokenize(string input){ stringstream oss(input); vector line; while(!oss.eof()){ string s; oss >> s; if(line.size() == 2 && line.at(0) == "push") line.push_back(s); else if(line.size() == 2 && line.at(0) == "pop") line.push_back(s); else if(line.size() == 2 && line.at(0) == "add") line.push_back(s); else if(line.size() == 2 && line.at(0) == "sub") line.push_back(s); else if(line.size() == 2 && line.at(0) == "mul") line.push_back(s); else if(line.size() == 2 && line.at(0) == "div") line.push_back(s); else if(line.size() == 2 && line.at(0) == "mod") line.push_back(s); else if(line.size() == 2 && line.at(0) == "skip") line.push_back(s); else if(line.size() == 2 && line.at(0) == "save") line.push_back(s); else if(line.size() == 2 && line.at(0) == "get") line.push_back(s); else throw ("Unexpected token: " + s); } this->data->push(line); } vector Tokenizer:: GetTokens(){ vector out; while(!this->data->empty()){

out = this->data->front(); this->data->pop(); } if(this->data->empty()) throw "No tokens"; return out; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions