The below code, is a source code which i am trying to learn double linked lists from, as for a 2nd year assignment.

For some reason my editor keeps returning the error messages

'cout' : undeclared identifier
'cin' : undeclared identifier

Can someone please help me??
All help is VERY much appreciated

/* Strictly --- Enter Only Integer Data otherwise It'll go in Infinite Loop */
#include <iostream>
#include <process.h>

class doubly
{
	doubly * next;
	doubly * pre;
	int data,ch;
public:
	doubly * link(doubly * );
	void traverse (doubly * );
};

doubly * doubly::link(doubly * temp)
{
	doubly * newlink;
	doubly * cur;
	newlink = new doubly;
	cout<<"\nEnter Element (only possitive number):";
	cin>>data;
	cur = temp;
	if(temp == NULL)
	{
		newlink->data = data;
		newlink->pre = NULL;
		newlink->next = NULL;
		temp = newlink;
		return temp;
	}

	else
	{
		while(cur->next != NULL)
		{		
			cur = cur->next ;
		}
		newlink->data = data;
		newlink->pre = cur;
		newlink->next = NULL;
		cur->next = newlink;	
		return temp;
	}
}


void doubly::traverse(doubly *temp)
{
	int ch;
	doubly * dummy;
	dummy = temp;
	cout<<"\n[1] Start From Begainning\n[2] Start From End\n";
	cout<<"\nEnter Your Choice  :";
	cin>>ch;
	switch(ch)
	{
	case 1:
		if(dummy != NULL)
		{
			while(temp->next !=NULL)
			{
				cout<<temp->data<<endl;
				temp=temp->next;
			}
			if (temp->next == NULL)
					cout<<temp->data<<endl;
		}
		break;
	case 2:
		if(temp != NULL)
		{
			temp = dummy;
			while(dummy->next !=NULL)
			{			
				dummy=dummy->next;
			}
			while(dummy->pre !=NULL)
			{
				cout<<dummy->data<<endl;
				dummy=dummy->pre;
				
			}
			if (dummy->pre == NULL)
					cout<<dummy->data<<endl;
		}
		break;
	}
}

void main()
{
	doubly *first=NULL,d1;
	int choice;
	while(1)
	{
		cout<<"\n************** DOUBLY LINK LIST **************\n\n";
		cout<<"Choices Are :-\n=>[1] For Insert \n=>[2] For Traverse \n=>[3] For Exit";
		cout<<"\n\nEnter Your choice : ";
		cin>>choice;

		switch (choice)
		{
		case 1:
			first=d1.link(first);
			break;		
		
		case 2:
			d1.traverse(first);
			break;
		case 3:
			exit(0);

		}
	
	}
}

You need to either put using namespace std; at the top or use std::cout and std::cin

hahah thankyou.

I honestly cannot believe i didnt see that.

THANKYOU again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.