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++

Recommended Answers

All 2 Replies

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);

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.