← Back to Question List
C++ Code Walkthrough #6
Static Variable in Function
📄 Code
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}