So what I am trying to do is to have a header file which declares lists in it. Everytime I complie it, it does not know what a list is. Here is my header file called MergeSort.h

#include<list>


class MergeSort{

 public:

  MergeSort();
  bool sortedIsEmpty();
  int sortedGetLenght();
  bool sortedInsert(int);
  bool sortedRemove(int);
  int sortedRetrieve(int);
  int locatePosition(bool);

 private:

  List<int> intergerList1;

};

Here is what the compiler spits at me:

MergeSort.h:18: error: ISO C++ forbids declaration of ‘List’ with no type
MergeSort.h:18: error: expected ‘;’ before ‘<’ token

Basically what I want to do is use this header file for this code called MergeSort.cpp

#include<iostream>
#include <list>
using namespace std;

#include "MergeSort.h"

list<int> integerList1;
list<int> integerList2;
list<int> integerList3;

int main(){

  


}

MergeSort::MergeSort(){

  //Empty constructor

}

bool MergeSort::sortedIsEmpty(){

  if(integerList3.empty()){

    return true;

  }else{

    return false;

  }

}

int MergeSort::sortedGetLenght(){

  return integerList3.size(); 

}

bool MergeSort::sortedInsert(list<int> first){



}

Now I dont have everything from teh .ccp file in the .h file yet. I am trying to get the .h file to complie first. Can anyone help me by letting me know how to declare a list in a headfer file? Thanks in advance.

C++ is case sensitive. Change it to list instead of List and if you don't do using namespace std; you have to prefix the name with std.

#include<list>


class MergeSort{

 public:

  MergeSort();
  bool sortedIsEmpty();
  int sortedGetLenght();
  bool sortedInsert(int);
  bool sortedRemove(int);
  int sortedRetrieve(int);
  int locatePosition(bool);

 private:

  std::list<int> intergerList1;

};

Thanks that worked like a charm

Thanks that worked like a charm

want to know that how many header files use in C++ or OOP,,,,,,,,if any bdy can answer me correct i will be very thank full to that person,,,,,thanks

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.