-3

I created a simple function in my cpp that prints out a text. Here's the code:

#include "Sally.h"
#include <iostream>
using namespace std;

Sally::Sally()
{

}

void Sally::tell(string t){

    cout << t << endl;

}

and here's how I prototype it on my .h file:

#ifndef SALLY_H
#define SALLY_H
class Sally
{
    public:

        Sally();
        void tell(string t);
    protected:

    private:
};

#endif // SALLY_H

Here are the errors:

Sally.h|8|error: 'string' has not been declared|
Sally::tell(std::__cxx11::string)' does not match any in class 'Sally'|
Sally.h|8|error: candidate is: void Sally::tell(int)|

It gives me an error whenever I build it. It doesn't have any problems at all if I'm using int as a parameter. So the problem is that I wish to use a string as a parameter.

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

1

do some changes to your .h file:

#include <string>

and add std:: in front of your string:

void tell(std::string t);
skeller
  • 1,151
  • 6
  • 6