-
Inheritance
what the hell? i didnt do anything wrong lol. so far as i can see...
linkedList.h
Code:
class linkedList:public linkedQueue
{
public:
linkedList();
~linkedList();
private:
};
linkedQueue.h
Code:
struct Node
{
int elem;
Node *next;
};
class linkedQueue
{
typedef int el_t;
public:
linkedQueue();
~linkedQueue();
void addRear(el_t newNum);
void deleteFront();
bool isEmpty();
int getSize();
void displayAll();
private:
int count;
Node *front,*rear,*temp;//front and rear used to show the front
//and the rear of the queue respectivley.
//temp is used for deleteing elements
void queueError(char* mesg);
};
it keeps saying 'expected class-name before '{' token'
-
Are you including linkedQueue.h in your linkedList.h?
--
Mats
-
ya i tried including it and not including it. this is what i have for the whole files...
linkedList.h
Code:
#ifndef linkedList_H
#define linkedList_H
#include<iostream>
#include "linkedQueue.h"
using namespace std;
class linkedList:public linkedQueue
{
public:
linkedList();
~linkedList();
void addFront(el_t newNum);
void deleteRear(el_t& oldNum);
int search(el_t& key);
void deleteIth(int I,el_t& oldNum);
private:
};
#endif //linkedList_H
linkedQueue.h
Code:
#ifndef linkedQueue_H
#define linkedQueue_H
#include<iostream>
using namespace std;
struct Node
{
int elem;
Node *next;
};
class linkedQueue
{
typedef int el_t;
public:
linkedQueue();
~linkedQueue();
void addRear(el_t newNum);
void deleteFront();
bool isEmpty();
int getSize();
void displayAll();
private:
int count;
Node *front,*rear,*temp;//front and rear used to show the front
//and the rear of the queue respectivley.
//temp is used for deleteing elements
void queueError(char* mesg);
};
#endif
-
Not sure what's wrong, but don't use "using namespace std" in a header-file - that wil screw up the entire system of "namespaces".
Oh, and don't put "Node *temp; // used for deleting" inside your class - it just occupies extra space, and since it's just a temporary that isn't needed for to be kept around, it's doesn't belong in the class - it belongs in the delete member function.
Can you post the exact error message with line numbers, please.
--
Mats
-
ooo, good advice about the temp thanks. i think i got it now, seemed to be something with my ide. it was telling me that i had invalid classes and they couldnt be found even though they were there, i messed around witht the project settings and seemed to have gotten it. btw which ide would you reccommend? im using dev C++ at the moment.
-
I'm a bit old-fashioned, so I often use Emacs and gcc on standalone - but Visual Studio Express is a slick environment with very good integration of all necessary tools - Windows only, of course.
--
Mats
-
ya ive still to try and use visual studio. well thanks a lot for all your advice, it really helped me out.
-
You should also make your destructors virtual, otherwise the wrong destructor might get called and leak resources.