So I have a "base" class called "SortData". When I try to allow my other header file "InsertionSort.h" inherit this base class, I keep getting a class type redefinition error. What am I doing wrong?

Here's the base class header:

// SortData.h

#include <iostream>

using namespace std;

class SortData
{
public:
	SortData(int max=100);
	~SortData(void);

	int size() const;
	void randomize(int seed = 1);
	void printSome(const int num=10) const;

	virtual _int64 sort() = 0;

protected:
	long *theData;
	int maxSize;
};

And here's the header that's trying to inherit this base class:

// InsertionSort.h

#include "SortData.h"

class InsertionSort : public SortData
{
public:
	InsertionSort(int max=100);
	~InsertionSort(void);
	_int64 sort();

private:
	_int64 numops;
	void insertionSort(long theArray[], int n);
};

Are you including both in main.cpp? This could be your problem and the solution is to use preprocessor blockers

SortData.h

#ifndef SORTDATA_H
#define SORTDATA_H

class SortData
{


};

#endif

And do the same thing for InsertionSort.h but with a different blocker name

Yeah I just realized that...sorry for the waste of forum space :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.