dimanche 19 août 2018

overwrite default enums from other class c++

Im stuck with a Problem in c++ right now.

header-file

class Date {
public:
Date(int day, int month, int year);
enum locale {
    de, us
};
enum length {
    Short, Long
};
void print(locale format = de, length l = Short);
};

[...]

void Date::print( Date::locale format, Date::length l){
if (format == de && l == Short) {

    cout << "de: " << d << "." << Monate[m-1] << "." << y;

}
if (format == de && l == Long) {

        cout << "de: " << d << Monate[m-1] << "." << y;

    }
if (format == us && l == Short) {

    cout << "en: " << m << "/" << d << "/" << y;

}
}

I'm not quite sure how i can use different parameters when calling the print function in my main class...

Main-Class

Date obj(20,10,2018);
obj.print(us,Long); 

above code is not working...

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire