Create a class containing an int, a constructor that initializes the int from its argument, and a print( ) function to display the int. Now create a second class that contains a static object of the first one. Add a static member function that calls the static object’s print( ) function. Exercise your class in main( ).
First class is OK,but second is problem.
#include <iostream>
using namespace std;
class I
{
int a;
public:
I(int i):a(i){};
void printi(){cout<<a<<endl;}
};
class S
{
static I obj;
public: