I've been scratching my head for quite some time with the following compilation error and I was hoping somebody could shed some light...

I have the following in my header (.h) file:

//the mem_data class======================================//
class mem_data : public reader, public date { //multiple inheritance

 public:
  mem_data(int,int,std::string);
  ~mem_data();

 private:
  std::vector<reader> mem_store;

};

Then, I have the following in the .cc file where I the code for the constructor/destructor is located:

//the mem_data class======================================//
mem_data::mem_data(int start_date,int ndays,string symbol) 
  : reader(std::string), date::date(std::string) {
  cout<<start_date<<endl;
}

mem_data::~mem_data() {}

Basically, the mem_data class is trying to inherit from the reader and date class.

When I compile, I am getting the following error

../../library/mem_data/mem_data.cc: In constructor ‘mem_data::mem_data(int, int, std::string)’:
../../library/mem_data/mem_data.cc:17: error: expected primary-expression before ‘)’ token
../../library/mem_data/mem_data.cc:17: error: expected primary-expression before ‘)’ token

Does anybody see what I am missing? I don't understand where I have screwed up the syntax.

First of all you should provide a default constructor for your class as for the error you're getting you should take a better look at your initialization list keeping in mind that you should provide valid arguments for the constructors of the classes you are inheriting from.

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.