-
August 26th, 2007, 02:28 AM
#1
[solved]29: error: ‘string’ does not name a type
Hi,
when try to compile my program I get the following message for this header file
Code:
#ifndef SENDSMS_H
#define SENDSMS_H
#include "ui_sendSMS.h"
#include <string>
class sendSMS : public QMainWindow, public Ui::MainWindow{
Q_OBJECT
public:
sendSMS (QMainWindow *parent = 0);
~sendSMS();
private slots:
void slotClose();
void calcChar();
void slotSend();
QString clean_string(QString);
QChar get_param(QString, int);
QString get_param_value(QString, int);
void process_line(QString);
void read_config_file();
private:
int maxChar;
QString param_filename;
string username;
string password;
string sourceno;
};
#endif
Ignore all the "Q" things, thats something Qt specific. int works fine, but not string. I have the string header included. I guess it is rather simple what is wrong....
Thanks,
J.
Last edited by joebar; August 26th, 2007 at 04:12 AM.
-
August 26th, 2007, 02:30 AM
#2
Re: 29: error: ‘string’ does not name a type
Use std::string instead of the unqualified string.
-
August 26th, 2007, 06:03 PM
#3
Re: 29: error: ‘string’ does not name a type
Another option is to use the following
One contentions issue is whether or not you should use namespace declarations in code, personally I find them confusing and laserlight's method is the one I choose to use, especially when dealing with multiple namespaces.
-
August 27th, 2007, 06:46 AM
#4
Re: 29: error: ‘string’ does not name a type
The use of namespace in headers is not recommended so go for laserlight's suggestion.
-
August 27th, 2007, 07:18 AM
#5
Re: 29: error: ‘string’ does not name a type
Hi,
thanks, but why is it not recommended? What is the problem here?
Thanks,
J.
-
August 27th, 2007, 07:57 AM
#6
Re: 29: error: ‘string’ does not name a type
Namespaces are meant to be used to separate things to avoid name clashes. If you in the future need to use two or more namespaces that have name clashes and all your headers already set a namespace you can't resolve this without editing the headers. I.e. it defeats the purpose of namespaces and it's very bad in a maintainance perspective.
I guess that not using "use namespace" at all as GuOddian say is the safest way to go but it also requires some extra typing that can be saved to when it's actually needed (names actually clash)
-
August 27th, 2007, 01:10 PM
#7
Re: 29: error: ‘string’ does not name a type
Another way would be:
That way you only import the string.
-
August 27th, 2007, 01:37 PM
#8
Re: 29: error: ‘string’ does not name a type
That way you only import the string.
That is still generally a Bad Thing in a header file.
-
August 28th, 2007, 08:02 AM
#9
Re: 29: error: ‘string’ does not name a type
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
|