K
kaferro
I have a base class that has about ten variables. Later, I have a
derived class that adds five more variables. In the derived class'
setData() function, I pass an instance of the base class, and use it to
set the derived class' base class variables. Is there a problem with
this structure?
//cComponent is the base class
void setData(cComponent tmpComponent, float tmpPosition, char
roll_or_new, int orderNum)
{
//trade date
date=date_today();
name=tmpComponent.returnName();
contract_code=tmpComponent.returnContract_code();
contract_month=tmpComponent.returnContract_month();
position=tmpPosition;
//need to set correctly !!!!
price=tmpComponent.returnPrice();
unit_multiplier=tmpComponent.returnUnitMult();
delivery_year=tmpComponent.returnDeliveryYear();;
symbol=tmpComponent.returnSymbol();
exchange=tmpComponent.returnExchange();
orderId=id_creator(orderNum);
//sets other data
if(position<0)
{ lots = position * -1;
order_b_s="S";
}
else
{ lots = position;
order_b_s="B";
}
if(roll_or_new == 'R' && order_b_s == "B")
{
order_memo="Closing Roll. Broker is instructed to check for
existing positions prior to execution.";
order_type="Cover";
}
else if(roll_or_new == 'R' && order_b_s == "S")
{
order_memo="Closing Roll. Broker is instructed to check for
existing positions prior to execution.";
order_type="Sell";
}
else if(roll_or_new == 'N' && order_b_s == "B")
{
order_memo="Adjusting Trade";
order_type="Buy";
}
else if(roll_or_new == 'N' && order_b_s == "S")
{
order_memo="Adjusting Trade";
order_type="Short";
}
else
{
order_memo="Error";
order_type="Error";
}
}
derived class that adds five more variables. In the derived class'
setData() function, I pass an instance of the base class, and use it to
set the derived class' base class variables. Is there a problem with
this structure?
//cComponent is the base class
void setData(cComponent tmpComponent, float tmpPosition, char
roll_or_new, int orderNum)
{
//trade date
date=date_today();
name=tmpComponent.returnName();
contract_code=tmpComponent.returnContract_code();
contract_month=tmpComponent.returnContract_month();
position=tmpPosition;
//need to set correctly !!!!
price=tmpComponent.returnPrice();
unit_multiplier=tmpComponent.returnUnitMult();
delivery_year=tmpComponent.returnDeliveryYear();;
symbol=tmpComponent.returnSymbol();
exchange=tmpComponent.returnExchange();
orderId=id_creator(orderNum);
//sets other data
if(position<0)
{ lots = position * -1;
order_b_s="S";
}
else
{ lots = position;
order_b_s="B";
}
if(roll_or_new == 'R' && order_b_s == "B")
{
order_memo="Closing Roll. Broker is instructed to check for
existing positions prior to execution.";
order_type="Cover";
}
else if(roll_or_new == 'R' && order_b_s == "S")
{
order_memo="Closing Roll. Broker is instructed to check for
existing positions prior to execution.";
order_type="Sell";
}
else if(roll_or_new == 'N' && order_b_s == "B")
{
order_memo="Adjusting Trade";
order_type="Buy";
}
else if(roll_or_new == 'N' && order_b_s == "S")
{
order_memo="Adjusting Trade";
order_type="Short";
}
else
{
order_memo="Error";
order_type="Error";
}
}