Back to Code Walkthrough
Static Variable in Function
C++ code walkthrough · Question 6Code
Read carefully. What does this print?1#include <iostream>2using namespace std;34int counter() {5 static int count = 0;6 count++;7 return count;8}910int main() {11 cout << counter() << endl;12 cout << counter() << endl;13 cout << counter() << endl;14 return 0;15}