how do you declare a Token in C++
#include<iostream>
using namespace std;
int main()
{
Token Token_stream::get() // Token_stream's member function get
{
// check if we already have a Token ready
if (fulli) { full=false; return buffer; }
char ch;
cin >> ch; // note that >> skips whitespace (space, newline, tab, etc.)
switch (ch) {
case '(': case ')': case ';': case 'q': case '+': case '-': case '*': case
'/':
return Token(ch); // let each character represent itself
case '.':
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case
'7': case '8': case '9':
{
cin.putback(); // put digit back into the input stream
double val;
cin >> val; // read a floating-point number
return Token('8',val); // let '8' represent 'a number'
}
default:
error("Bad token");
}
}
9.cpp: In function `int main()':
9.cpp:5: `Token' undeclared (first use this function)
9.cpp:5: (Each undeclared identifier is reported only once for each
function it appears in.)
9.cpp:5: parse error before `::' token
9.cpp:8: `buffer' undeclared (first use this function)
9.cpp: At global scope:
9.cpp:10: syntax error before `>>' token
9.cpp:19: syntax error before `>>' token
---------------------------------
Never miss a thing. Make Yahoo your homepage.
[Non-text portions of this message have been removed]