473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

is this main program right to this class?

i want u to check this main program if it is right? plz

Enum error_code{overflow,under flow,success};
Const int maxstack=100;
Template<class stacktype>
Class stack{
Private:
Stacktype entry [maxstack];
int count;
public:
stack();
error_code push(const stacktype & item);
erroe_code pop();
eror_code top(stacktype &item) const;
bool empty() const;
bool full() const;
void clear();
int size() const;
};
Template<class stacktype>
Error_code stack<stacktype>::push(const stacktype &item)
{if (full())
Return overflow;
Entry[count]=item;
Count++;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype>::top(stacktype &item) const
{
if (empty())
Return underflow;
Entry[count-1]=item;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype>::pop( )
{
if (empty())
Return underflow;
Count--;
Return success;
}

Void main()
{stack<int> obj;
Obj.push("john");
Obj.push("sarah");
If (obj.push("malak")!=success)
{
Cout<<"problem"<<endl;
Exit(1);
}
Obj.pop();
Temp="salam";
Obj.top(temp);
Cout<<temp<<endl;
}//end of main
Dec 27 '06 #1
1 1207
willakawill
1,646 1GB
i want u to check this main program if it is right? plz
Hi does it do what you want it to do?
Dec 27 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

192
by: Kwan Ting | last post by:
The_Sage, I see you've gotten yourself a twin asking for program in comp.lang.c++ . http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=45cd1b289c71c33c&rnum=1 If you the oh so mighty...
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
5
by: Henry Jordon | last post by:
hello I was wondering if someone could help me get a main going on this project I've completed the header file that the professor started us on but not really sure how to get the main going. If...
4
by: wongjoekmeu | last post by:
Hello All, >From a book where I have learned C++ it says that each application must have at least one function which is the main() function. Now I have the source code of a C++ program from...
15
by: Fred Zwarts | last post by:
In C++ execution of a program starts already before execution of main(). The initialization of static variables defined outside the scope of main is performed first. I could imagine a program where...
6
by: Marc | last post by:
I am just starting out teaching myself C#, and I have come accross a confusing point in my book. It seems that any class can have a Main() function, but what does that mean? Is the Main() function...
2
by: Gustaf Liljegren | last post by:
This is a very general question of style. I'm often writing console programs that takes one input file and returns an output file. They use to look something like this: class Program { public...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
9
by: tiyaramunna | last post by:
I am trying to configure my system with Java program just to practice on the coding....when i compile a test.java program i am able to see the class file but i cant run the program ... I am getting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.