c++ compile error
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:
Can you help with this problem?
Provide an answer of your own, or ask Gaurav for more information if necessary.