Hi,
i have to solve the following exercise. Write a constructor for the class testArray which uses the "new" operator to assign anaraay of 10 integers to the int pointer IntArray. The constructor should have a single argument which is used to assign an initial value to each array element. The default value for the argument should be 10. Write a main() routine which declares a testArray object and uses the PrintData() funtion to print out its IntArray fiels.
this is the given class:
1 2 3 4 5 6 7 8 9 10
class testArray
{
private:
int *intArray;
public:
/// add constructor
void PrintData();
};
#endif
and the PrintData() function.
Here my solution.
testArray.h file
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#ifndef TESTARRAY_H
#define TESTARRAY_H
#include <vector>
class testArray
{
private:
int *intArray;
public:
testArray(int arg);
void PrintData();
};
#endif