Problem bei der Dekleration von 2 Klassen



  • hallo folgendes, wenn ich jenes ausführe meldet der Compiler immer "DateFormat has not been declared"
    wie was wo hab ich denn da vergessen?

    datum.h
    
    #ifndef KALENDER_H_INCLUDED
    #define KALENDER_H_INCLUDED
    using namespace std;
    
    class Date{
        private:
        int day,month,year;
    
        public:
        int getDayInYear();
        int getDayInMonth();
        int getWeekInYear();
        bool isLeapYear();
        string toString();
        Date(void);
        void setFormat(DateFormat f);
    
    };
    
    class DateFormat{
        private:
        string format(Date d);
        static Date parse(string s);
    
        public:
        DateFormat(void);
    
    };
    


  • #ifndef KALENDER_H_INCLUDED
    #define KALENDER_H_INCLUDED
    using namespace std;
    
    class DateFormat; //<-------------------
    
    class Date{
        private:
        int day,month,year;
    
        public:
        int getDayInYear();
        int getDayInMonth();
        int getWeekInYear();
        bool isLeapYear();
        string toString();
        Date(void);
        void setFormat(const DateFormat & f); // <----------------
    
    };
    
    class DateFormat{
        private:
        string format(Date d);
        static Date parse(string s);
    
        public:
        DateFormat(void);
    
    };
    


  • ah danke, ist also genauso zu deklarieren wie ne Funktion


Log in to reply