Original Post
All is going well code-wise apparently. No compiler errors..........it outputs all of the numbers onto the screen properly. But there is no big problem. At the end of the program.....(in Windows XP) I get a pop-up dialog box that tells me that the application I''m running has a problem. Here is the code.
~Source
#include <iostream>
#include <cstdlib>
#include "Main.h"
using std::cout;
using std::cin;
int main(void)
{
CArray<int, 20, 0> array;
SetRandom( array );
PrintArray( array );
cin.get();
return EXIT_SUCCESS;
}
void SetRandom( CArray<int, 20, 0> pArray )
{
srand( (int)time(0) );
for( int i = 0; i < pArray.Size(); i++ )
{
pArray.SetElement( i, rand() % 50 );
}
}
void PrintArray( CArray<int, 20, 0> array )
{
for( int i = 0; i < array.Size(); i++ )
{
cout << array.GetElement( i ) << ", ";
}
}
~Header File
#ifndef _Main_h
#define _Main_h
template<class dataType, int size, dataType zero>
class CArray
{
dataType * _array;
public:
CArray(void) { }
void SetElement( int index, dataType value )
{
_array[index] = value;
}
void ClearElement( int index )
{
_array[index] = zero;
}
dataType GetElement( int index )
{
return( _array[index] );
}
int Size(void) const
{
return size;
}
};
void SetRandom(CArray<int, 20, 0>);
void PrintArray(CArray<int, 20, 0>);
#endif
--------
"Do you believe in Ghost?"