I have created many functions which I wish to use but am unsure whether they should be inserted in to the class as a member function. I am wondering if this problem is leading to the failure of the class to compile. I have written the errors which I am getting getting next to where the problem lies.
Thank you
#include <iostream>
#include <cstdlib>
using namespace std;
class badger_susceptible{
int AdMs,AdFs,JuvMs,JuvFs,CubMs,CubFs; //unqualified if before ; token
//variables need updating each step
public:
badger_susceptible(); //constructor
double Birth(B); //functions expected ; before ()
double Death(D); // " "
double Immig(Imigration);
double Emig(Emigration);
double SE() const {return StoE;} // return badger s to e// StoE undeclared first use function
double EI() const {return EtoI;}
double JuvAdult(JuvtoAdult); //functions expected ; before ()
double CubJuv(CubtoJuv); //functions expected ; before ()
~badger_susceptible(); //destructor
};
int main ()
{
badger_susceptible AdMs; expected ; before AdMs
AdMs.Birth(); // class has no member named Birth
AdMs.SE(); // " "
AdMs.EI()
AdMs.Immig();
AdMs.Emig();
You parameter lists are incomplete in your function declarations. Each parameter entry must specify a type and a name (the name isn't required in the declaration, but is required in the definition). You are only specifying the parameter names. ie:
double Birth(B);
What is the type of parameter B (assuming you haven't defined some type somewhere as called B). It should be something like:
double Birth(int B);
AdMs.Birth(); // class has no member named Birth This is generating an error because you haven't defined a member function Birth that takes zero parameters. You can either do this by overloading member function Birth with a declaration that takes no parameters, or define your existing member function Birth with 1 parameter that has a default value.
Either this:
I am afraid that I haven't been able to figure out where this primary expression should be. I've tried various modes.
Thank you,
#include <iostream>
#include <cstdlib>
using namespace std;
class badger_susceptible{
int& AdMs,AdFs,JuvMs,JuvFs,CubMs,CubFs; //variables need updating each step
public:
badger_susceptible(); //constructor
double Birth (float& B); //function updated with each time step
double Death (float& D); // function updated with each time step
double Immig (float& Imigration);// function updated with each time step
double Emig (float& Emigration);// function updated with each time step
double SE (float StoE) const {return StoE;} // return badger s to e, constant values
double EI (float EtoI) const {return EtoI;} // return badger s to e, constant values
double JuvAdult (float& JuvtoAdult); // function updated with each time step
double CubJuv (float& CubtoJuv); // function updated with each time step
~badger_susceptible(); //destructor
};