1

Ok im trying to compile and keep getting this error: 38 ISO C++ forbids declaration of `string' with no type. Not sure what im doing wrong. Here is my code:

my header file:

#ifndef PLAYER_H
#define PLAYER_H
#include <iostream>
using namespace std;

class MyString
{
	public:

	int find(const string& str);


};
#endif

My functions file:

#include "Player.h"



int MyString::find(const string& str)
{

}

my main:

#include "Player.h"
       
          
int main()
{}

Any suggestions? Sorry new to c++

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by nated
0

It means the compiler doesn't know what string is. You failed to include <string> header file. After doing that, you need to declare strings as being part of std namespace: int find(const std::string& str);

0

Ah ok that seems to fix it. Thank you for the help :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.