Derived Constructor having issues, outside of scope?

I'm making a derived class for a project, here's the code"

#include <iostream>
#include <stdlib.h>

using namespace std;

class Shopper
{
public:
Shopper(int yrs_a_mbr,double av_mnth_prchs, char *sh_nm);
Shopper operator <<(Shopper);
~Shopper();
int years_a_member;
double avg_monthly_purchases;
double membership_cost;
double nominal_membership_cost = 50;
void set_membership_cost();
double get_membership_cost();
char * get_shopper_name();
private:
char *shopper_name;


};


Shopper::Shopper(int yrs_a_mbr,double av_mnth_prchs, char *sh_nm): years_a_member(yrs_a_mbr)
{
av_mnth_prchs = 250;
shopper_name = sh_nm;
shopper_name = new char[100];
avg_monthly_purchases = av_mnth_prchs;
cout << "Object is being created" << endl;

};

Shopper Shopper::operator<<(Shopper shpr)
{
cout << shopper_name << "has a yearly membership cost of: " << membership_cost << endl;
}

Shopper::~Shopper()
{
cout << "Object is being deleted" << endl;
}

void Shopper::set_membership_cost()
{
if (years_a_member < 5)
{
membership_cost = nominal_membership_cost - (0.5*(0.01*avg_monthly_purchases)) - (nominal_membership_cost * (0.04*years_a_member));
} else {
membership_cost = 30;
}

}

double Shopper::get_membership_cost()
{
membership_cost += 2;
}

char* get_shopper_name()
{}



class family_shopper: public Shopper
{

public:
family_shopper(int yrs_a_mbr, double av_mnth_prchs, char* f_sh_nm,double fam_disc );

private:
double family_discount;

};

family_shopper::family_shopper(int yrs_a_mbr, double av_mnth_prchs, char *f_sh_nm, double fam_disc)
:Shopper(yrs_a_mbr, av_mnth_prchs, sh_nm)
{
fam_disc = family_discount;
family_discount = 10;
yrs_a_mbr = 2;
av_mnth_prchs = 100;

};


int main(){

cout << "test" << endl;
return 0;

}

The compiler is return an error on the derived constructor, saying the "sh_nm" was not declared in this scope. I don't understand, did I call the case constructor wrong?
1
2
3
4
5
6
7
8
9
10
11
12
family_shopper::family_shopper(
   int yrs_a_mbr,
   double av_mnth_prchs,
   char *f_sh_nm,
   double fam_disc
)
:Shopper(
   yrs_a_mbr,
   av_mnth_prchs,
   sh_nm //¿where is this defined? you have asked for f_sh_nm, ¿did you mean that?
)
{


Also, read the warnings, when you say that you are going to return something from a function, then do it.
Topic archived. No new replies allowed.