S. Kartik
S. Kartik

Reputation: 49

string cannot start a parameter declaration

I am getting the following compilation errors:

bool isRotated(string str1, string str2)  
{

}

'string' cannot start a parameter declaration

) expected

Header files included are:

iostream.h
string.h

Am I missing something here?

Upvotes: 0

Views: 3031

Answers (2)

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385104

Neither iostream.h nor string.h exist in C++*, and the type is called std::string.

You seem to be learning from an extremely old resource (outdating what we actually call C++ since 1998).

#include <string>

bool isRotated(std::string str1, std::string str2)
{
}

* Pedants will note that string.h is included for compatibility with C, but is better known as cstring and is regardless not at all the same header that you are intending to use here.

Upvotes: 2

eerorika
eerorika

Reputation: 238311

There is no fully qualified type name string in C++ standard library. All standard library types are declared in the std namespace, so the name of the type that you're looking for is std::string. Also, you did not include the header which declares std::string: <string> (<string.h> is a completely different header, part of the C standard library which is included in C++ standard library).

P.S. <iostream.h> header is not standard - although it was used by some compilers prior to standardization. You're looking for <iostream>. Although, your example doesn't use anything from that header.

Upvotes: 1

Related Questions