c++ compile error

Asked by Gaurav

dears
I m new to Ubuntu. i m using ubuntu 8.10
I get these error when i was trying to compile c++ simple program. i use g++ to complie
error are:

test.cpp:2:18: error: conio.h: No such file or directory
test.cpp:21: error: stray ‘`’ in program
test.cpp:54: error: function definition does not declare parameters
test.cpp: In function ‘int main()’:
test.cpp:83: error: expected `:' before ‘cout’

source code is

#include<iostream>
#include<conio.h>
#define N 10

using namespace std;

int choice, flag=1;
class stack
{
 private:
   int a[N];
   int top;
 public:
 stack()
 {
 top=-1;
 }
 void push (int x)
 {
  if(top>N-1)
` {
  cout << "stack is full";
  }
  else
  {
   top=top+1;
   a[top]=x;
  }
 }
 int pop()
 {
  if(top<0)
  {
   cout << "Stack is empty";
   return 0;
  }
  else
  {
   int y=a[top];
   top=top-1;
   return y;
  }
 }
 void display();
};
void menu()
{
 cout << "\n 1. \t Push";
 cout << "\n 2. \t Pop";
 cout << "\n 3. \t Display";
 cout << "\n 4. \t Quit";
 cout << "\n Enter your choice ...";
}
void stack: display()
{
 int i;
 for(i=0; i<=top; i++)
 {
  cout << a[i];
 }
}
int main()
{
 stack obj;
 int no, p;
 do
 {

  menu();
  cin >> choice;
  switch(choice)
  {
   case 1:
   cout << "Enter a no";
   cin >> no;
   obj.push(no);
   break;
   case 2:
   cout << "Pop is running";
   p=obj.pop();
   break;
   case 3
   cout << "Displaying stack element";
   obj.display();
   break;
   case 4:
   cout << "Quiting from program";
   flag=0;
   break;
   default:
   cout << "Invalid options";
  }

 }while(flag==1);
return 0;

}

what to do ????
i need some help????

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
marcobra (Marco Braida) (marcobra) said :
#1

Seems like this http://ubuntuforums.org/showthread.php?t=508713

Hope this helps

Revision history for this message
Antonio Litterio (antonio-litterio-gmail) said :
#2

Hi Gaurav in your program there is two problems.
First is a sample error, add a column after "case 3" -> "case 3:"
The second problem is conio library not installed.

Can you help with this problem?

Provide an answer of your own, or ask Gaurav for more information if necessary.

To post a message you must log in.