I was trying to overload assignment operator for this Class. How to do this for class containing Structures and enumerators?
class Config
{
public:
Config() { SetDefaults(); }
Config(const std::string& path);
enum FeatureType
{
kFeatureTypeHaar,
kFeatureTypeRaw,
};
enum KernelType
{
kKernelTypeLinear,
kKernelTypeGaussian };
struct FeatureKernelPair
{
FeatureType feature;
KernelType kernel;
std::vector<double> params;
};
bool quietMode;
std::string sequenceBasePath
int frameHeight;
std::vector<FeatureKernelPair> features;
friend std::ostream& operator<< (std::ostream& out, const Config& conf);
private:
void SetDefaults();
static std::string FeatureName(FeatureType f);
static std::string KernelName(KernelType k);
};
This is what i had tried. This is the general way to do it,right..?
Config & operator=(Config const&c) {
if(this != &c){
quietMode = c.quietMode;
sequenceBasePath = c.sequenceBasePath;
frameHeight = c.frameHeight;
features = c.features;
}
return *this;
}