Code:
//stack.h
#ifndef stackh
#define Stackh
class Stack
{
public:
stack();
void create();
void push(char &ch, POKC &vrh):
char pop(char &ch, POKC &vrh);
int vrh();
bool isEmpty;
void brisi();
private:
enum { capacity = 21 };
char data[capacity];
int current;
};
#endif
//stack.h
#ifndef stackh
#define Stackh
class Stack
{
public:
stack();
void create();
void push(char &ch, POKC &vrh):
char pop(char &ch, POKC &vrh);
int vrh();
bool isEmpty;
void brisi();
private:
enum { capacity = 21 };
char data[capacity];
int current;
};
#endif
Code:
//stack.cpp
#include <iostream>
#include "Stack.h"
using namespace std;
typedef struct cvor
{
char inf;
struct cvor *sledeci;
}CVOR;
typedef CVOR* POKC;
void push (char &ch, POKC &vrh)
{
POKC novi;
novi=new cvor;
novi ->inf=ch;
novi->sledeci=vrh;
vrh=novi;
}
void pop(char &ch, POKC &vrh)
{
POKC pomocni;
ch=vrh->inf;
pomocni=vrh;
vrh=vrh->sledeci;
delete pomocni;
}
void pisi (POKC vrh)
{
char ch;
while(vrh!=NULL)
{
pop(ch, vrh);
putchar(ch);
}
}
bool isEmpty()
{
int i;
for(i=0;i<capacity;i++)
{
if (data[i]=='/0')
continue;
else
return false;
}
return true;
}
void brisi()
{
for (int i=0; i<capacity;i++)
data[i]='\0';
}
//stack.cpp
#include <iostream>
#include "Stack.h"
using namespace std;
typedef struct cvor
{
char inf;
struct cvor *sledeci;
}CVOR;
typedef CVOR* POKC;
void push (char &ch, POKC &vrh)
{
POKC novi;
novi=new cvor;
novi ->inf=ch;
novi->sledeci=vrh;
vrh=novi;
}
void pop(char &ch, POKC &vrh)
{
POKC pomocni;
ch=vrh->inf;
pomocni=vrh;
vrh=vrh->sledeci;
delete pomocni;
}
void pisi (POKC vrh)
{
char ch;
while(vrh!=NULL)
{
pop(ch, vrh);
putchar(ch);
}
}
bool isEmpty()
{
int i;
for(i=0;i<capacity;i++)
{
if (data[i]=='/0')
continue;
else
return false;
}
return true;
}
void brisi()
{
for (int i=0; i<capacity;i++)
data[i]='\0';
}
ovo sam za sada uradio i ispisuje mi dosta gresaka tipa
Code:
error C2065: 'capacity' : undeclared identifier
error C2065: 'data' : undeclared identifier
error C2062: type 'void' unexpected - u stack.h
error C2065: 'capacity' : undeclared identifier
error C2065: 'data' : undeclared identifier
error C2062: type 'void' unexpected - u stack.h
kako bi trebao da povezem ova dva fajla?