This is what you get for using namespace std;
(std
has a left
too). And you don't even need iostream
. The reference to left
is ambiguous.
Do this:
#include <cstdlib>
struct elem{
int key;
elem *next;
} *left=NULL,*right=NULL;
void push_l(int n){
elem *p=left;
left=new elem;
left->key=n;
left->next=p;
if (right==NULL)right=left;
}
int main(){
push_l(5);
std::system("pause");
return 0;
}