Hello everybody, can someone tell me how to fix those errors

array.h:21: error: redefinition of âclass Array<DataType>â
array.h:22: error: previous definition of âclass Array<DataType>â

// THOSE ERROR HAPEND WHEN I CALL FROM THE PROGRAM USEARRAY.CPP
arra#ifndef INC_ARRAY_H
#define INC_ARRAY_H
#endif
#if _MSC_VER > 1000
#pragma once
#endif


#include <string>

using namespace std;

template <class DataType>
class Array //HERE IS THE REDEFINITIONS LINE 21
{
public:
Array( int size );
Array( const Array<DataType> & ap );
~Array( );
Array<DataType> & operator =( const Array<DataType> & right );
inline DataType & operator [ ]( int index );
void changeSize( int newSize ); // will not alter values unless newSize is smaller
// than current capacity; in this case, the values
// from 0 to newSize - 1 will not be altered
inline int length( ) const; // returns the current capacity of the array
string err( ) const; // returns error message from errorCode
private:
DataType *elements; // points to the dynamic array
int capacity;
DataType dud; // returned from operator [ ] if index error occurs
int errorCode; // contains code for error if array misuse occurs
inline void deepCopy( const Array<DataType> & original );
};

y.h:22: error: previous definition of âclass Array<DataType>â
Last edited on
Syntax errors. Have you included the header file?
closed account (z05DSL3A)
Fatal Error C1014

Error Message
too many include files : depth = level

The nesting of #include directives is too deep. Nested directives can include open files. The source file containing the directive counts as one file.
From MSDN


So you have probably got a cyclic include somewhere in your code.
Last edited on
yes I do in the header file array.h but in the template that is the source file not
Why don't you just post Array.h and Array.cpp.

(Although I think that your template class should all be in one file Array.H not split into 2 files).
closed account (z05DSL3A)
Olove5, Why did you totally change the question and title of this topic and not just ad your new problem to the end? (or better still post a new topic for your new problem).

Topic archived. No new replies allowed.