CWinApp theApp;
#include <iostream.h>
#include <string.h>
★#include <mem.h>
enum boolean { false, true };
class stack {
public:
stack();
stack(int size);
stack(const char p[]);
stack(const stack& sptr);
~stack() {delete []s; }
void clear() {top = EMPTY; }
void push(cha c) { s[++top] = c; }
char pop() { return (s[top--]; }
char top_of() const { return (s[top]; }
boolean empty() const { return (boolean) (top == EMPTY); }
boolean full() const {return (boolean) (top == max_len-1);}
private:
enum {EMPTY = -1};
char* s;
int max_len;
int top;
};
stack::stak()
{
s = new char[100];
max_len = 100;
top = EMPTY;
}
stack::stack(int size)
{
s = new char[size];
max_len = size;
top = EMPTY;
}
stack::stack(const char p[])
{
max_len = strlen(p);
s=new char[max_len];
for (int i = 0; i< max_len && p[i] !=0; ++i)
s[i] = p[i];
top = --i;
}
stack::stack(const stack&sptr)
{
s=new char[sptr.max_len];
max_len = sptr.max_len;
top = sptr.top;
memcpy(s, sptr.s, max_len);
}
void main()
{
stack a,b("Welcome to the C++!"), c(b), d;
int i;
char ch;
for(i=0; i<26; i++) a.push('a' + i);
for(i=0; i<26; i++) cout << a.pop();
cout << endl;
while (b.empty() != true) cout << b.pop();
cout << endl;
while(c.empty() !=true) {
ch = c.pop();
d.push(ch);
}
while (d.empty() !=true) cout << d.pop();
cout << endl;
}
★된 부분에서 오류가 나왔습니다.
Cannot open include file: 'mem.h': No such file or directory
헤더파일이 없어서 나타난거 같았는데
아무리 찾아봐도 헤더파일을 찾을수가 없는데...
어떻게 해야되나요?ㅠㅠ
꼭 답변 부탁드립니다ㅠㅠ