I got one code:
Code:
#include <iostream>
using namespace std;

class objekat
{
      int test;

      public:

      void definiraj_test(int a){ test=a; };

      void pecati_test(){ cout<<test<<endl;}
};


int main()
{
    objekat *pokazuvac;
    
    pokazuvac = new objekat;
    
    for(int i=0;i<5;i++)
    {
          pokazuvac[i].definiraj_test(i);
    }
    
    for(int i=0;i<5;i++)
    {
            pokazuvac[i].pecati_test();
    }
    
    system("PAUSE");
    
}
There is pointer which points to class "objekat". Also there are functions which define and print the private variable "test".

First I declare the pointer objekat *pokazuvac;. Then pokazuvac = new objekat;.

Now the pointer points to one object. But what if I do something like:

Code:
 for(int i=0;i<5;i++)
    {
          pokazuvac[i].definiraj_test(i);
    }
Why it still works? The pointer points to one object, and not array of objects??


Thanks in advance.