I'm trying to write a function with objects:
void System::SetBetaParameter()
{
if(conditions)
{
cBetaOne.m_bState = ENGAGED;
}
else if(alternate conditions)
{
cBetaOne.m_bState = DISENGAGED;
}
}
void System::SetBetaParameter()
{
if(conditions)
{
cBetaOne.m_bState = ENGAGED;
}
else if(alternate conditions)
{
cBetaOne.m_bState = DISENGAGED;
}
}
To copy to clipboard, switch view to plain text mode
My case is simple with just two conditions and two objects, so theoretically I can just write two if loops testing for type of object being tested, but this is very cumbersome and I'm more interested in doing it by passing by reference or as a pointer.
Question that I have is, should I do the following:
System.h
#include "beta.h"
class System
{
Beta cBetaOne, cBetaTwo;
Beta *cBetaOne, *cBetaTwo;
}
#include "beta.h"
class System
{
Beta cBetaOne, cBetaTwo;
Beta *cBetaOne, *cBetaTwo;
}
To copy to clipboard, switch view to plain text mode
Simply create the objects and then use their pointers after setting those pointers to correspond to those objects in the constructor or should I dynamically allocate those objects using new in the constructor and go from there?
Bookmarks