HeaderFile:
CPP file:Code:
#ifndef __CSHAPE_H
#define __CSHAPE_H
#include <string.h>
#include <iostream.h>
class cSHAPE
{
protected: //Member Variables
char* ptrName;
public: //Methods
//Constructor
cSHAPE(const char* ptr)
{
ptrName=NULL;
if (ptr)
{
ptrName = new char[strlen(ptr)+1];
strcpy(ptrName,ptr);
}
}
~cSHAPE()
{
if (ptrName)
delete[] ptrName;
}
const char* getName()
{
return(ptrName);
}
virtual void displayShape() = 0;
virtual void eraseShape() = 0;
};
{
public:
cCIRCLE():cSHAPE("Circle")
{}
void displayShape()
{
cout << "- " << ptrName << " has a radius "<< endl;
}
void eraseShape()
{
cout << "- " << "Erasing:" << ptrName << endl;
}
};
class cTRIANGLE:public cSHAPE
{
public:
cTRIANGLE():cSHAPE("Triangle")
{}
void displayShape()
{
cout << "- " << ptrName << " can be located in Bermuda "<< endl;
}
void eraseShape()
{
cout << "- " << "Erasing:" << ptrName<< endl;
}
};
#endif
i want to declare arSHAPE as an array pf 3 pointers to cSHAPE and initilize each object in the arrayCode:#include "cshape.h"
#include <iostream.h>
const int MAX = 3;
void main (void)
{
cCIRCLE c1;
cTRIANGLE t1;
cRECTANGLE r1;
cSHAPE arShape(MAX); <---------ERROR
}
