I am trying to change a certain text box message. It will display my output.
This is what I have in my main()
#include "form2.h"
....
string recvMSG = "random";
182:: Form2::changeOutput(recvMSG); ...
within my form2.h I have:
#include <string.h>
#include <iostream>
#include <stdlib.h>
...
void Form2::changeOutput(string s)
{
QString s1 = i18n(s);
output_box.setText(s1);
}
But i still get: .ui/form2.h:56: error: ‘string’ has not been declared
Thanks.
Edit:: kk so now its showing:: TCPClient.cpp:182: error: cannot call member function ‘virtual void Form2::changeOutput(std::string)’ without object
string
is in the std
namespace, so you either need to refer to it as std::string
, or you need to make the name available in the current scope with using namespace std;
or using std::string;
.
Also the header is called string
, not string.h
, so include it this way:
#include <string>
Generally you also might want to use QT's QString
instead of std::string
if you are using it in connection with QT components that usually take QString
parameters.
I guess you should use the header <string>
and then use std::string
(even better would be const std::string &
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With