What will be printed out as a result of the following code execution?

#include <iostream>
using namespace std;

struct SomeType {
    void someMethod();
    static int cnt;

int SomeType::cnt;

void SomeType::someMethod() {
   cout << "cnt" << cnt;

int main() {
  SomeType someVar;
  SomeType *ptrSomeType = new SomeType();      
  delete ptrSomeType;
  return 0;
Static variables (global, local, members of the class etc.) are always initialized with zero. (*ptrSomeType).someMethod(); and (&someVar)->someMethod(); calls are equivalent.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes