Main
static void Main(string[] args)
{
string name = "Me";
int height = 130;
double weight = 65.5;
BMI patient1 = new BMI();
BMI patient2 = new BMI(name,height,weight);
Console.WriteLine(patient2.Get_height.ToString() + Environment.NewLine + patient1.Get_height.ToString() );
Console.ReadLine();
}
Base Class
class BMI
{
//memberVariables
private string newName;
private int newHeight;
private double newWeight;
//default constructor
public BMI(){}
//overloaded constructor
public BMI(string name, int height, double weight)
{
newName = name;
newHeight = height;
newWeight = weight;
}
//poperties
public string Get_Name
{
get { return newName; }
set { newName = value;}
}
public int Get_height
{
get { return newHeight; }
set { newHeight = value; }
}
public double Get_weight
{
get { return newWeight; }
set { newWeight = value; }
}
}
derived class
class Health : BMI
{
private int newSize;
public Health(int Size):base()
{
newSize = Size;
}
}
How do i pass in the base parameters from the overloaded constructor in the BMI base class into the Derived Class? Any time i try to pass them into the base parameters i get invalid expression error. Or do i just have to pass them into a Health object in the main with a ? eg
class Health : BMI
{
private int newSize;
public Health(int Size, string Name, int Height, double Weight)
{
newSize = Size;
base.Get_Name = Name
base.Get_weight = Weight;
base.Get_height = Height;
}
}