I am new in C++. When I compile this code compiler reports error-
main.cpp-
#include <iostream>
#include <string>
#include "main.h"
using namespace std;
string strings::getstr(string str)
{
return str;
}
int main()
{
strings strstr;
string constr;
string msg;
msg = "Hello World!";
constr = strstr.getstr(msg);
cout << constr;
return 0;
}
main.h-
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include <string>
class strings
{
public:
string getstr (string str);
};
#endif // MAIN_H_INCLUDED
error-
error: 'string' does not name a type
error: no 'std::string strings::getstr(std::string)' member function declared in class 'strings'
error: In function 'int main()':
error: 'class strings' has no member named 'getstr'
I am using Code::Blocks and gcc I have written this simple code because I am working on a project and when I want to compile I always getting
'string' does not name a type
sorry for bad english...