I'm new for this forum, and because this I don't know is this the right place to post my question about the container class stack.
I'm trying to make a program, in which there is a stack. The stack is filled with information.
I am using Visual C++ 6.0.
Here is the source code of the program.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stack>
class Chenko{
public:
Chenko();
Chenko(int x,char *y);
void Show()const;
virtual Ednakyv(const Chenko&);
~Chenko();
private:
int edno;
char *dve;
};
char buff_dve[11]; //pomo6tna promenliva za pyrviq konstruktor
Chenko::Chenko()
{
printf("Vyvedete 4islo za edno:");scanf("%d",&edno);
printf("Vyvedete duma za dve:");gets(buff_dve);
dve=new char[strlen(buff_dve)];
strcpy(dve,buff_dve);
}
Chenko::Chenko(int x,char *y)
{
edno=x;
dve=new char[strlen(y)+1];
strcpy(dve,y);
}
void Chenko::Show()const
{
printf("Edno e | %d | , a dve e | %s |",edno,dve);
}
Chenko::Ednakyv(const Chenko&)
{
}
Chenko::~Chenko()
{
}
void main()
{
Stack<Chenko> theStack;
Chenko *buffer;
int x;char *y;char ch;
do {
printf("Vyvedete X:");scanf("%d",&x);
printf("Vyvedete Y:");gets(y);
buffer=new Chenko(x,y);
Chenko& opsa=*buffer;
theStack.push(opsa);
printf("Shall I proceed?");ch=getchar();getchar();getchar();
delete []buffer;
}
while(ch!='n');
}
I know that there might be very big and silly mistakes, but my big problem is the stack. I can't include it. I have different things to include it (#include <stack>, #include "stack",#include <stack.h>, #include "stack.h").
But the program says: "What the fuck is stack?". I think I'm on the right way, because I'm looking in pdf file, part of my OOP book.
So tell me, where is the problem, because I can't find it. If you have any suggestions how to improve my program, tell. :)
Thank you very much. You're my hero. But can you tell what the hell is this thing that I'm using. I'll search it in internet for detailed information, but it will be really nice if you do this too. I will read all the things to make picture in my mind how the things work. from first sight it looks like I'm telling the stack with what I will fill it. std looks like class, but stack is also a class, and this is really confusing. And from where did it came std.
Once more, thank you for the fast answer. I was searching in internet for hours to make possible picture in my mind how the things should work. I even installed Visual C++ 9.0 Express Edition 2008. I was on the way to install even DevC++.
Bow
PS
@Galik, thanks for the advice. Next time will use this link to post source codes. Thank you.