void main1() { const int MAX = 50; class infix { private: char target[MAX], stack[MAX]; char *s, *t; int top, l; public: infix( ); void setexpr ( char *str ); void push ( char c ); char pop( ); void convert( ); int priority ( char c ); void show( ); }; void infix :: infix( ) //error { top = -1; strcpy ( target, "" ); strcpy ( stack, "" ); l = 0; } void infix :: setexpr ( char *str )//error { s = str; strrev ( s ); l = strlen ( s ); * ( target + l ) = '\0'; t = target + ( l - 1 ); } void infix :: push ( char c )//error { if ( top == MAX - 1 ) cout << "\nStack is full\n"; else { top++ ; stack[top] = c; } } }
I am having trouble with this code. This is a part of my code for infix to prefix converter. My compiler keeps giving me the error:
“A function-declaration is not allowed here – before ‘{‘ token”
There’s actually three errors in this project. My project is due in September 2015, so please help! Thanks in advance.