0
#include "B.h"
class A
{
public :
    A()
    {
        s_b = new B();
        b = new B();
    }
    static B s_b ;
    B b ;
};
#include<iostream>
using namespace std ;
#include "A.h"
int main()
{
    cout<<"hello";
}

In my project i have seen static object as above . But not able to know what is the exact use of it and how they are different from general object . Please help me in finding out What all the things i can do with s_b which is not being done by b .

Thanks in advance . :)

Edited by deceptikon: Fixed indentation

3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by deceptikon
1

A static class member exists on a class level as opposed to non-static class members that exist on an object level. For example, what you can do with s_b but not with b is access it without having an "A" object, as it's not part of an object but of a class. Every object will have it's own "b" though.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.