0

Using string data type without string header file

The below code shows that a "greeting" function is using "greet" argument with "string" data type without "string" header file #include <iostream> using namespace std; void greeting(string greet, int repeats) { for (int i = 0; i < repeats; i++) cout << greet << endl; } int main() { greeting("Hi!", 5); } how can the code run without identifying the "string" data type?

29th May 2022, 7:39 PM
Ahmad
Ahmad - avatar
1 Odpowiedź
+ 3
It's sometime indirectly included by the implementation writers while implementing iostream. But this is not standard behaviour and thus it's always a good idea to include necessary header in your programs.
30th May 2022, 3:42 AM
Arsenic
Arsenic - avatar