Hi anyone.
Please help with this seperate compilation.

Many thanks !

//pointerDataClass ;Header file

class pointerDataClass
    void print() const;
    //Function to output the value of x and
    //the value of the array p.
    void setData();
    //Function to input data into x and
    //into the array p.
    void destroyP();
    //Function to deallocate the memory space
    //occupied bt the array p.
    pointerDataClass(int sizeP = 10);
    //Create an array of the size specified by the
    //parameter sizeP; the default array size is 10.
    //Deallocate the memory space occupied by the array p.
    pointerDataClass (const pointerDataClass& otherObject);
    //copy constructor
    int x;
    int lenP;
    int *p;        //pointer to an int array

//pointerDataClassIMP ; this is the implementation file

#include <iostream>
#include "pointerDataClass.h"

void pointerDataClass::print() const
    cout << "x = " << x << endl;
    cout << "p = ";
    for (int i = 0; i < lenP; i++)
        cout << p[i] << " ";
    cout << endl;

void pointerDataClass::setData()
    cout << "Enter an integer for x: ";
    cin >> x;
    cout << endl;
    cout << "Enter " << lenP << " numbers: ";
    for (int i = 0; i < lenP; i++)
        cin >> p[i];
    cout << endl;

void pointerDataClass::destroyP()
    lenP = 0;
    delete [] p;
    p = NULL;

pointerDataClass::pointerDataClass(int sizeP)
    x = 0;
    if (sizeP <= 0)
      cout << "Array size must be positive." << endl;
      cout << "Creating an array of size 10." << endl;
      lenP = 10;
      lenP = sizeP;
    p = new int[lenP];
    assert(p != NULL);

    delete [] p;

//copy constructor
pointerDataClass::pointerDataClass(const pointerDataClass& otherObject)
    x = otherObject.x;
    lenP = otherObject.lenP;
    p = new int[lenP];
    assert(p != NULL);
    for (int i = 0; i < lenP; i++)
        p[i] = otherObject.p[i];
#include <iostream>
#include "pointerDataClass.h"
using namespace std;

int main() {

    pointerDataClass regClass;
  return 0;

The compiler is pointing to line 2 in Main.
Am i not including the header file correctly ??
Please advise.

This is the error message in the compile log:

Compiler: Default compiler
Building Makefile: "C:\unisa\devcpp\Makefile.win"
Executing make...
gmake.exe -f "C:\unisa\devcpp\Makefile.win" all
Execution terminated

Please refer to the attachment to see whether there are files in my project directory.


Attachments filetypes.JPG 110.02 KB

Will you zip up that directory and attach it so that I can check it out? My guess is that you didn't make the project correctly. But that is just a guess.

Ancient Dragon .. i have to run will be back !!
Thanks for your help thus far.
I'll reply when i'm back online again.

all you had to do was add using statements at the top of the program, and it compiled/linked ok for me.

//pointerDataClassIMP       ; this is the implementation file
#include <iostream>
#include "pointerDataClass.h"
using std::cout;
using std::endl;
using std::cin;

I have a small question, why do you use the void destroyp function when you have a class destructor that appears to do the same thing?

And not to beat a dead horse as AD is an expert, but I too saw the including of namespace in the main, but not in the class implementation

This article has been dead for over six months. Start a new discussion instead.