string not included error
Code:
#ifndef LINES_H_INCLUDED
#define LINES_H_INCLUDED
#include <string>
/** @file Lines.h */
typedef string ListItemType;
/** class Lines*/
class Lines
{
private:
/** A node in the list*/
struct Node
{
ListItemType item;
Node *next;
int lines;
};
Node *head;
public:
/** Default Constructor*/
Lines();
/** Copy Constructor*
* @param line = The list to copy*/
Lines(const Lines& line);
/** Destructor */
~Lines();
//List operations
void insert(int index, const ListItemType& newItem);
void remove(int index);
void copy(int index, ListItemType& dataItem) const;
void cut(int index,ListItemType& dataItem);
};
#endif // LINES_H_INCLUDED
This is the header file for a link list, when i try to compile this, it produces an error stating "string is not included"
when i change the string to => typedef char ListItemType
there's no problem...
Re: string not included error
In an h file, you need to fully quality it as std::string.
Re: string not included error
or specify namespace std, but Lindley's way is prefered
Re: string not included error
Quote:
Originally Posted by
ninja9578
or specify namespace std, but Lindley's way is prefered
It's not a good idea to specify a "using" statement in a header file (at least, in an unrestricted scope) because that defeats the purpose of namespaces.
Re: string not included error
Hense why I said your way is preferred, but you can.
Re: string not included error
I figured that, but I wanted the reason for it on the record.