what is the reason i am getting out put is 111?

Posted by kam on Stack Overflow See other posts from Stack Overflow or by kam
Published on 2010-05-13T11:46:52Z Indexed on 2010/05/13 11:54 UTC
Read the original article Hit count: 160

Filed under:

Hi,

#include "stdafx.h"
#include<iostream.h>

template<class T>
class Sample
{
    public:
        Sample();
        static int i;



};
template<class T>
int Sample<T>::i = 0;
template<class T>
Sample<T>::Sample()
{
    i++;
    cout<<i;
}

void main()
{
    Sample<int>s1;
    Sample<float>s2;
    Sample<char>s3;
}

output: 111

what is the reason i am getting out put is 111?

© Stack Overflow or respective owner

Related posts about c++