Perfectly it is valid to create the pointers which point to the classes.
A D V E R T I S E M E N T
Simply we have
to consider, after declaration, a class will become valid type, so we can make use of
the class name as a type for pointer. Take for example:
CRectangle * prect;
This is the pointer to object of the class CRectangle.
As with data structures, in order to refer to member of an
object pointed by the pointer directly, we can use an arrow operator (->) of
the indirection. Consider the following example.
// pointer to classes example
#include <iostream>
using namespace std;
class CRectangle
{
int width, height;
public:
void set_values (int, int);
int area (void)
{
return (width * height);
}
};
void CRectangle::set_values (int a, int b)
{
width = a;
height = b;
}
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords Pointers to classes, c++ pointers, c# pointers, function pointers, const pointers,
struct pointers, string pointers, array pointers, void pointers, functions pointers,
pointers to structs, pointers arrays, pointers char, structures pointers,
reference pointers, programming pointers, pointers to objects, passing pointers,
to conversion, classes language, using pointers, to char, to array, convert to,
to string, java to, c# to, to integer, to byte