2. Array is a collection of variable of same data types.
Similarly, array of class objects means a collection of
objects of same types.
Hence, an array having class type element is known as
array of object.
syntax:
Class_name object_name [size];
5. What is Pointer?
-Pointer means the variable that stores the address
of another variable.
6. A pointer can point to an object created by class.
Example: abc ob;
Here abc=class and ob=object of class abc.
we can define pointer of type abc as below:
abc *ptr;
Object pointers are useful in creating objects at run
time.
7. We can also use an object pointer to access the public
members of class.
We can access to member function of abc in two ways:
1)by using (.) dot operator
ex:- (*ptr).show();
2)by using () arrow operator
ex:- ptrshow();
8. Example of Pointer to
object:
#include<iostream.h>
#include<conio.h>
class abc
{
int a,b,ADD;
public:
void getdata()
{
cout<<"Enter the values:" ;
cin>>a>>b;
}
void display()
{
ADD=a+b;
cout<<"Sum="<<ADD;
}
};
int main()
{
clrscr();
abc *ob;
(*ob).getdata();
ob->display();
getch();
return 0;
}