0

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?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
S. Kartik
  • 49
  • 2
  • 7
  • please provide [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). This could be caused by number of things. If your code is short, please post it, not just the function – Fureeish Jul 08 '17 at 01:05
  • `std::string` ? – Serge Jul 08 '17 at 01:05
  • 3
    iostream.h? Are you learning C++ from a 20 year old book? – Blastfurnace Jul 08 '17 at 01:05
  • I am using TurboC++, I used include and did not work, so used iostream.h – S. Kartik Jul 08 '17 at 01:13
  • You aren't going to learn very well with ancient tools and references. Start with a more current compiler and maybe [one of these books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Blastfurnace Jul 08 '17 at 01:26
  • @S.Kartik if you use and ask about turbo c++, you should use the tag [[turboc++](https://stackoverflow.com/questions/tagged/turboc%2b%2b)]. If you tag just [c++], people will assume that you're using and asking about standard c++. – eerorika Jul 08 '17 at 01:32

2 Answers2

2

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.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
1

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.

eerorika
  • 232,697
  • 12
  • 197
  • 326