-
July 29th, 2010, 09:14 AM
#1
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...
-
July 29th, 2010, 09:17 AM
#2
Re: string not included error
In an h file, you need to fully quality it as std::string.
-
July 29th, 2010, 09:23 AM
#3
Re: string not included error
or specify namespace std, but Lindley's way is prefered
-
July 29th, 2010, 09:30 AM
#4
Re: string not included error
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.
-
July 29th, 2010, 01:16 PM
#5
Re: string not included error
Hense why I said your way is preferred, but you can.
-
July 29th, 2010, 01:19 PM
#6
Re: string not included error
I figured that, but I wanted the reason for it on the record.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|