I wrote class like this:
#pragma once
#include "stdafx.h"
struct Date
{
private:
int day;
int year;
enum Month {jan = 1,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec};
Month* month;
enum date_state
{
good,err_flag, bad_day, bad_month, bad_year,
};
//I would like to define converting operator from enum to char
Date::date_state::operator char()
{
return err_flag;
}
date_state err_state;
void clear(date_state state = good);
date_state rdstate() const;
void check_day(const int d)const;
void check_month()const;
void check_year()const;
public:
Date(const int d,const Date::Month& m, const int y);
};
and basically it doesn’t work.
You can’t declare member functions for
enum date_state, because it is an enum, but you could do so forclass Date:But would rather recommend using a normal member function instead, because a conversion operator might easily be used accidently.