Local Class

// Localclass.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream>
using namespace std;
void f();
void f()
{
static int a;
class myclass {
int i;
public:
void put_i(int n)
{
i=n;
a= 10;
}
int get_i() { return i; }
} ob;

ob.put_i(10);
cout << ob.get_i();
}
int _tmain(int argc, _TCHAR* argv[])
{
f();
return 0;
}

Comments

Popular posts from this blog

Smart Pointers in C++ and How to Use Them

Operator Overloading in C++

How would you read in a string of unknown length without risking buffer overflow