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?
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.