ENUM not previously declared

I am getting these errors:

C:\Daily Tax Exempt\Guest.h|24|error: use of enum 'GetPayment' without previous declaration|
C:\Daily Tax Exempt\Guest.h|24|error: expected unqualified-id before ')' token|
C:\Daily Tax Exempt\Guest.h|25|error: 'Payment' has not been declared|
C:\Daily Tax Exempt\Guest.h|37|error: 'm_Payment' does not name a type|
C:\Daily Tax Exempt\Guest.h||In member function 'void Guest::SetPayment(int)':|
C:\Daily Tax Exempt\Guest.h|25|error: 'm_Payment' was not declared in this scope|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 3 seconds) ===|


with this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef GUEST_H
#define GUEST_H

#include <string>


class Guest
{
    public:
        Guest();
        virtual ~Guest();
        std::string GetDate_Month() { return m_Date_Month; }
        void SetDate_Month(std::string val) { m_Date_Month = val; }
        std::string GetName() { return m_Name; }
        void SetName(std::string val) { m_Name = val; }
        std::string GetGroup_Company() { return m_Group_Company; }
        void SetGroup_Company(std::string val) { m_Group_Company = val; }
        int GetFolio() { return m_Folio; }
        void SetFolio(int val) { m_Folio = val; }
        int GetRoom() { return m_Room; }
        void SetRoom(int val) { m_Room = val; }
        int GetNights() { return m_Nights; }
        void SetNights(int val) { m_Nights = val; }
        enum GetPayment() { return m_Payment; }
        void SetPayment(Payment val) { m_Payment = val; }
        enum Payment {ALLW, AX, CHK, CLC, CLP, DB, DC, DS, MC, CASH, CB, GIFT, JC, VS, XC, ZZ};
        std::string GetReason() { return m_Reason; }
        void SetReason(std::string val) { m_Reason = val; }
    protected:
    private:
        std::string m_Date_Month;
        std::string m_Name;
        std::string m_Group_Company;
        int m_Folio;
        int m_Room;
        int m_Nights;
        m_Payment Payment;
        std::string m_Reason;
};

#endif // GUEST_H 


I don't know why I am getting those errors. Cannot someone please help me figure this out?
GetPayment is not an enum, it returns an enum type called Payment. So the declaration has to be Payment GetPayment(). Now, remember that in C++ things have to be declared before you use them. On lines 24, 25, the compiler hasn't seen what Payment is yet. Move line 26 up before 24. Lastly, what is with line 37? Variable declarations are "Type Name" while you wrote "Name Type".

Also, this is a bit had to read. Newline is your friend.
Last edited on
Thanks once again, for your help, hamsterman.

P.S. I want to put this in a database or at least a text file to be printed monthly. Any ideas where I should start?
What is "this" ? If you want your code interact with a database, you need a library like sqlite or something more sophisticated. I have very little experience with this tough.
I am not going to use sqlite or any other database. I just want to be able to put it in a binary file and also have it printable on command. I can put all of this in a text file. I just can't seem to read a text file into variables in my programs. I'd rather not have the save file as a text file though. That way no one can change the file through a text editor.
Well, if you're having problems with file io, you should probably start a new thread about it, showing what you want and what you've tried.
Thanks again for your help hamsterman. :)
Topic archived. No new replies allowed.