Class Methods Multipile Definitions

This is a discussion on Class Methods Multipile Definitions within the C++ Programming forums, part of the General Programming Boards category; I have a ton of errors all like this one: gui_color.h|7|multiple definition of `GUI_COLOR::GetColor()' Ive already did a search for ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    Exclamation Class Methods Multipile Definitions

    I have a ton of errors all like this one:

    gui_color.h|7|multiple definition of `GUI_COLOR::GetColor()'

    Ive already did a search for "multiple definitions" and nothing was helping.

    heres the code though for you to look at and spot my problem, i just cant find it. I just hope someone knows where i got lost at. Thanks for your time.

    main.cpp
    Code:
    // main.cpp
    #define _WIN32_WINNT 0x0601
    
    #include "console.h"
    
    using namespace std;
    
    int main()
    {
        HANDLE hIn;
        HANDLE hOut;
    
        CONSOLE_SCREEN_BUFFER_INFO csbi;
    
        int i = 0;
    
        bool Continue = TRUE;
        DWORD EventCount;
        int LoopCount = 0;
        int KeyEvents = 0;
        INPUT_RECORD InRec;
        DWORD NumRead;
    
        hIn = GetStdHandle(STD_INPUT_HANDLE);
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        ChangeScreenBufferSize(hOut, true, 128, 256);
        MaximizeConsoleWindowSize(hOut);
    
        while (Continue)
        {
    
            GetNumberOfConsoleInputEvents(hIn, &EventCount);
    
            while (EventCount > 0)
            {
                ReadConsoleInput(hIn, &InRec, 1, &NumRead);
    
                if (InRec.EventType == KEY_EVENT)
                {
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'a')
                    {
                        ClearScreen(hOut);
    
                        //DrawBox(hOut, box1);
    
                        //Displaying the ASCII Table
    
                        int x = 0;
                        int y = 0;
    
                        for(i = 0; i <= 255; i++)
                        {
                            MoveCursor(hOut, x, y);
                            cout << " # " << i << " " << (unsigned char) i << flush;
    
                            ++y;
    
                            if(y > 20)
                            {
                                y = 0;
                                x += 9;
                            }
                        }
    
                        //
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'b')
                    {
                        SMALL_RECT srBoxArea;
    
                        srBoxArea.Top = 2;
                        srBoxArea.Bottom = 32;
                        srBoxArea.Left = 2;
                        srBoxArea.Right = 32;
    
                        DrawBox(hOut, srBoxArea);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'c')
                    {
                        ChangeCursor(hOut, 1, false);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'd')
                    {
                        DecrementConsoleWindowSize(hOut);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'i')
                    {
                        IncrementConsoleWindowSize(hOut);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'm')
                    {
                        MaximizeConsoleWindowSize(hOut);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'o')
                    {
    
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'x')
                    {
                        Continue = FALSE;
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == 'w')
                    {
                        ClearScreen(hOut);
                    }
    
                    if (InRec.Event.KeyEvent.uChar.AsciiChar == '?')
                    {
                        GetConsoleScreenBufferInfo(hOut, &csbi);
    
                        ClearScreen(hOut);
                        MoveCursor(hOut, 0, 0); cout << "CONSOLE_SCREEN_BUFFER_INFO :" << flush;
                        MoveCursor(hOut, 5, 2); cout << "dwSize :" << flush;
                        MoveCursor(hOut, 5, 3); cout << "X = " << csbi.dwSize.X << flush;
                        MoveCursor(hOut, 5, 4); cout << "Y = " << csbi.dwSize.Y << flush;
                        MoveCursor(hOut, 5, 6); cout << "srWindow :" << flush;
                        MoveCursor(hOut, 5, 7); cout << "Right = " << csbi.srWindow.Right << flush;
                        MoveCursor(hOut, 5, 8); cout << "Bottom = " << csbi.srWindow.Bottom << flush;
                        MoveCursor(hOut, 5, 10); cout << "dwMaximumWindowSize :" << flush;
                        MoveCursor(hOut, 5, 11); cout << "X = " << csbi.dwMaximumWindowSize.X << flush;
                        MoveCursor(hOut, 5, 12); cout << "X = " << csbi.dwMaximumWindowSize.Y << flush;
                    }
                }
                else if (InRec.EventType == MOUSE_EVENT)
                {
                    if (InRec.Event.MouseEvent.dwEventFlags == 0)
                    {
                        if (InRec.Event.MouseEvent.dwButtonState & 0x01)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
    
                        if (InRec.Event.MouseEvent.dwButtonState & 0x02)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == MOUSE_MOVED)
                    {
                        //cout << InRec.Event.MouseEvent.dwMousePosition.X << "," << InRec.Event.MouseEvent.dwMousePosition.Y << "  " << flush;
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK)
                    {
                        //cout << InRec.Event.MouseEvent.dwMousePosition.X << "," << InRec.Event.MouseEvent.dwMousePosition.Y << "  " << flush;
                    }
                    else if (InRec.Event.MouseEvent.dwEventFlags == MOUSE_WHEELED)
                    {
                        // Caution: Non-MSDN documented technique
                        if (InRec.Event.MouseEvent.dwButtonState & 0xFF000000)
                        {
                            // Down
                        }
                        else
                        {
                            // Up
                        }
                    }
                }
    
                GetNumberOfConsoleInputEvents(hIn, &EventCount);
            }
        }
    
        return 0;
    }
    cosole.cpp
    Code:
    // console.cpp
    #include <windows.h>
    #include <wincon.h>
    #include <iostream>
    
    #include "gui_box.h"
    
    // Custom Console Functions: Prototypes
    
    void ClearScreen(HANDLE hOut);
    void ChangeCursor(HANDLE hOut,int iSize, bool bVisable);
    void MoveCursor(HANDLE hOut, COORD Pos);
    void MoveCursor(HANDLE hOut, int iX, int iY);
    void SetColor(HANDLE hOut, int iForeColor, int iBackColor);
    void MaximizeConsoleWindowSize(HANDLE hOut);
    void IncrementConsoleWindowSize(HANDLE hOut);
    void IncrementConsoleWindowSize(HANDLE hOut, int iInc);
    void DecrementConsoleWindowSize(HANDLE hOut);
    void DecrementConsoleWindowSize(HANDLE hOut, int iDec);
    // Todo
    void ChangeConsoleWindowSize(HANDLE hOut, bool bAbsolute, int iX, int iY);
    void ChangeScreenBufferSize(HANDLE hOut, bool bAbsolute, int iX, int iY);
    
    void DrawBox(HANDLE hOut, SMALL_RECT srBoxArea);
    void DrawBox(HANDLE hOut, GUI_BOX gbBox);
    console.h
    Code:
    // console.h
    #ifndef CONSOLE_H_INCLUDED
    #define CONSOLE_H_INCLUDED
    
    #include "console.cpp"
    
    
    // Color definations:
    
    #define FBlack      0
    #define FRed        FOREGROUND_RED
    #define FGreen      FOREGROUND_GREEN
    #define FBlue       FOREGROUND_BLUE
    #define FYellow     FORGROUND_RED | FORGROUND_GREEN
    #define FCyan       FOREGROUND_GREEN | FOREGROUND_BLUE
    #define FMagenta    FOREGROUND_RED | FOREGROUND_BLUE
    #define FWhite      FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
    
    #define FRedI       FOREGROUND_RED | FOREGROUND_INTENSITY
    #define FGreenI     FOREGROUND_GREEN | FOREGROUND_INTENSITY
    #define FBlueI      FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FYellowI    FORGROUND_RED | FORGROUND_GREEN | FOREGROUND_INTENSITY
    #define FCyanI      FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FMagentaI   FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    #define FWhiteI     FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
    
    #define BBlack      0
    #define BRed        BACKGROUND_RED
    #define BGreen      BACKGROUND_GREEN
    #define BBlue       BACKGROUND_BLUE
    #define BYellow     BACKGROUND_RED | BACKGROUND_GREEN
    #define BCyan       BACKGROUND_GREEN | BACKGROUND_BLUE
    #define BMagenta    BACKGROUND_RED | BACKGROUND_BLUE
    #define BWhite      BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
    
    #define BRedI       BACKGROUND_RED | BACKGROUND_INTENSITY
    #define BGreenI     BACKGROUND_GREEN | BACKGROUND_INTENSITY
    #define BBlueI      BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BYellowI    BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY
    #define BCyanI      BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BMagentaI   BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    #define BWhiteI     BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY
    
    using namespace std;
    
    // Custom Data Types
    
    // Custom Console Functions: Implementaions
    
    void ClearScreen(HANDLE hOut)
    {
        CONSOLE_SCREEN_BUFFER_INFO SBInfo;
        int ScreenTotal;
        COORD Position;
        DWORD Written;
    
        Position.X = 0;
        Position.Y = 0;
    
        GetConsoleScreenBufferInfo(hOut, &SBInfo);
    
        ScreenTotal = SBInfo.dwSize.X * SBInfo.dwSize.Y;
    
        FillConsoleOutputCharacter(hOut, ' ', ScreenTotal, Position, &Written);
    }
    
    void ChangeCursor(HANDLE hOut, int iSize, bool bVisable)
    {
        CONSOLE_CURSOR_INFO ConCurInf;
    
        ConCurInf.dwSize = iSize;
        ConCurInf.bVisible = bVisable;
    
        SetConsoleCursorInfo(hOut, &ConCurInf);
    }
    
    void MoveCursor(HANDLE hOut, COORD Pos)
    {
        SetConsoleCursorPosition(hOut, Pos);
    }
    
    void MoveCursor(HANDLE hOut, int iX, int iY)
    {
        COORD Pos;
    
        Pos.X = iX;
        Pos.Y = iY;
    
        SetConsoleCursorPosition(hOut, Pos);
    }
    
    void SetColor(HANDLE hOut, int iForeColor, int iBackColor)
    {
       SetConsoleTextAttribute(hOut, iForeColor | iBackColor);
    }
    
    void MaximizeConsoleWindowSize(HANDLE hOut)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        DisplayArea.Right = csbi.dwMaximumWindowSize.X-1;
        DisplayArea.Bottom = csbi.dwMaximumWindowSize.Y-1;
    
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    void IncrementConsoleWindowSize(HANDLE hOut)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        if((csbi.srWindow.Right+1) < (csbi.dwMaximumWindowSize.X))
        {
            DisplayArea.Right = csbi.srWindow.Right + 1;
        }
        else
        {
            DisplayArea.Right = csbi.dwMaximumWindowSize.X - 1;
        }
    
        if((csbi.srWindow.Bottom+1) < (csbi.dwMaximumWindowSize.Y))
        {
            DisplayArea.Bottom = csbi.srWindow.Bottom + 1;
        }
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    void IncrementConsoleWindowSize(HANDLE hOut, int iInc)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        if((csbi.srWindow.Right + iInc) < (csbi.dwMaximumWindowSize.X))
        {
            DisplayArea.Right = csbi.srWindow.Right + 1;
        }
        else
        {
            DisplayArea.Right = csbi.dwMaximumWindowSize.X - 1;
        }
    
        if((csbi.srWindow.Bottom + iInc) < (csbi.dwMaximumWindowSize.Y))
        {
            DisplayArea.Bottom = csbi.dwMaximumWindowSize.Y - 1;
        }
        else
        {
            DisplayArea.Bottom = csbi.srWindow.Bottom + 1;
        }
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    void DecrementConsoleWindowSize(HANDLE hOut)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        if((csbi.srWindow.Right - 1) >= 0)
        {
            DisplayArea.Right = csbi.srWindow.Right - 1;
        }
    
        if((csbi.srWindow.Bottom - 1) >= 0)
        {
            DisplayArea.Bottom = csbi.srWindow.Bottom - 1;
        }
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    void DecrementConsoleWindowSize(HANDLE hOut, int iDec)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        if((csbi.srWindow.Right - iDec) >= 0)
        {
            DisplayArea.Right = csbi.srWindow.Right - 1;
        }
    
        if((csbi.srWindow.Bottom + iDec) >= 0)
        {
            DisplayArea.Bottom = csbi.srWindow.Bottom - 1;
        }
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    // Todo: Add individual functions for incrementing and decrememting the window size in just one direction at a time.
    
    void ChangeConsoleWindowSize(HANDLE hOut, bool bAbsolute, int iX, int iY)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        SMALL_RECT DisplayArea;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        DisplayArea.Left = 0;
        DisplayArea.Top = 0;
    
        if(bAbsolute)
        {
            if(iX >= 0)
            {
                DisplayArea.Right = iX;
            }
            else
            {
                DisplayArea.Right = 0;
            }
    
            if(iY >= 0)
            {
                DisplayArea.Bottom = iY;
            }
            else
            {
                DisplayArea.Bottom = 0;
            }
    
        }
        else
        {
            if(iX >= 0)
            {
                if((csbi.srWindow.Right + iX) < csbi.dwMaximumWindowSize.X)
                {
                    DisplayArea.Right = csbi.srWindow.Right + iX;
                }
                else
                {
                    DisplayArea.Right = csbi.dwMaximumWindowSize.X - 1;
                }
            }
    
            if(iY >= 0)
            {
                if((csbi.srWindow.Bottom + iY) < csbi.dwMaximumWindowSize.Y)
                {
                    DisplayArea.Bottom = csbi.srWindow.Bottom + iY;
                }
                else
                {
                    DisplayArea.Bottom = csbi.dwMaximumWindowSize.Y - 1;
                }
            }
    
        }
    
    
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);
    }
    
    void ChangeScreenBufferSize(HANDLE hOut, bool bAbsolute, int iX, int iY)
    {
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        COORD newcsbs;
    
        GetConsoleScreenBufferInfo(hOut, &csbi);
    
        if(bAbsolute)
        {
            newcsbs.X = iX;
            newcsbs.Y = iY;
        }
        else
        {
            newcsbs.X = csbi.dwSize.X + iX;
            newcsbs.Y = csbi.dwSize.Y + iY;
        }
    
    
        SetConsoleScreenBufferSize(hOut, newcsbs);
    }
    
    void DrawBox(HANDLE hOut, SMALL_RECT srBoxArea)
    {
        int i = 0;
        COORD TopLeft, TopRight, BottomLeft, BottomRight;
    
        TopLeft.X = srBoxArea.Left;
        TopLeft.Y = srBoxArea.Top;
    
        TopRight.X = srBoxArea.Right;
        TopRight.Y = srBoxArea.Top;
    
        BottomLeft.X = srBoxArea.Left;
        BottomLeft.Y = srBoxArea.Bottom;
    
        BottomRight.X = srBoxArea.Right;
        BottomRight.Y = srBoxArea.Bottom;
    
        MoveCursor(hOut, TopLeft); cout << "+";
        MoveCursor(hOut, TopRight); cout << "+";
        MoveCursor(hOut, BottomLeft); cout << "+";
        MoveCursor(hOut, BottomRight); cout << "+";
    
        for(i = TopLeft.X + 1; i < TopRight.X; i++)
        {
            MoveCursor(hOut, i, srBoxArea.Top); cout << "-";
        }
    
        for(i = BottomLeft.X + 1; i < BottomRight.X; i++)
        {
            MoveCursor(hOut, i, srBoxArea.Bottom); cout << "-";
        }
    
        for(i = TopLeft.Y + 1; i < BottomLeft.Y; i++)
        {
            MoveCursor(hOut, srBoxArea.Left, i); cout << "|";
        }
    
        for(i = TopRight.Y + 1; i < BottomRight.Y; i++)
        {
            MoveCursor(hOut, srBoxArea.Right, i); cout << "|";
        }
    }
    
    void DrawBox(HANDLE hOut, GUI_BOX gbBox)
    {
        int i = 0;
    
        MoveCursor(hOut, gbBox.GetTopLeft()); cout << "+";
        MoveCursor(hOut, gbBox.GetTopRight()); cout << "+";
        MoveCursor(hOut, gbBox.GetBottomLeft()); cout << "+";
        MoveCursor(hOut, gbBox.GetBottomRight()); cout << "+";
    
        for(i = (gbBox.GetTopLeft()).X + 1; i < (gbBox.GetTopRight()).X; i++)
        {
            MoveCursor(hOut, i, gbBox.GetTop()); cout << "-";
        }
    
        for(i = (gbBox.GetBottomLeft()).X + 1; i < (gbBox.GetBottomRight()).X; i++)
        {
            MoveCursor(hOut, i, gbBox.GetBottom()); cout << "-";
        }
    
        for(i = (gbBox.GetTopLeft()).Y + 1; i < (gbBox.GetBottomLeft()).Y; i++)
        {
            MoveCursor(hOut, gbBox.GetLeft(), i); cout << "|";
        }
    
        for(i = (gbBox.GetTopRight()).Y + 1; i < (gbBox.GetBottomRight()).Y; i++)
        {
            MoveCursor(hOut, gbBox.GetRight(), i); cout << "|";
        }
    }
    #endif // CONSOLE_H_INCLUDED
    gui_box.cpp
    Code:
    // gui_box.cpp
    #include "gui_color.h"
    
    class GUI_BOX
    {
        public:
    
            GUI_COLOR GetBoxBoarderColor();
            GUI_COLOR GetBoxFillColor();
            SMALL_RECT GetBoxRect();
    
            int GetTop();
            int GetBottom();
            int GetLeft();
            int GetRight();
    
            COORD GetTopLeft();
            COORD GetTopRight();
            COORD GetBottomLeft();
            COORD GetBottomRight();
    
            void SetBoarderColor(GUI_COLOR);
            void SetFillColor(GUI_COLOR);
            void SetBoxRect(SMALL_RECT);
            void SetBoxRect(int, int, int, int);
    
            GUI_BOX();
            //GUI_BOX(GUI_BOX);
            GUI_BOX(int, int, int, int, GUI_COLOR, GUI_COLOR);
            GUI_BOX(SMALL_RECT, GUI_COLOR, GUI_COLOR);
            GUI_BOX(int, int, int, int, int, int, int, int);
            GUI_BOX(SMALL_RECT, int, int, int, int);
    
            ~GUI_BOX();
    
        private:
    
            GUI_COLOR gcBoxBoarderColor, gcBoxFillColor;
            SMALL_RECT srBoxRect;
            COORD cdTopLeft, cdTopRight, cdBottomLeft, cdBottomRight;
    
            void CalcBoxCorners();
    };
    gui_box.h
    Code:
    //gui_box.h
    #ifndef GUI_BOX_H_INCLUDED
    #define GUI_BOX_H_INCLUDED
    
    #include "gui_box.cpp"
    
    GUI_COLOR GUI_BOX::GetBoxBoarderColor()
    {
        return gcBoxBoarderColor;
    }
    
    GUI_COLOR GUI_BOX::GetBoxFillColor()
    {
        return gcBoxFillColor;
    }
    
    SMALL_RECT GUI_BOX::GetBoxRect()
    {
        return srBoxRect;
    }
    
    int GUI_BOX::GetTop()
    {
        return srBoxRect.Top;
    }
    
    int GUI_BOX::GetBottom()
    {
        return srBoxRect.Bottom;
    }
    
    int GUI_BOX::GetLeft()
    {
        return srBoxRect.Left;
    }
    
    int GUI_BOX::GetRight()
    {
        return srBoxRect.Right;
    }
    
    COORD GUI_BOX::GetTopLeft()
    {
        return cdTopLeft;
    }
    
    COORD GUI_BOX::GetTopRight()
    {
        return cdTopRight;
    }
    
    COORD GUI_BOX::GetBottomLeft()
    {
        return cdBottomLeft;
    }
    
    COORD GUI_BOX::GetBottomRight()
    {
        return cdBottomRight;
    }
    
    void GUI_BOX::SetBoarderColor(GUI_COLOR gc)
    {
        gcBoxBoarderColor = gc;
    }
    
    void GUI_BOX::SetFillColor(GUI_COLOR gc)
    {
        gcBoxFillColor = gc;
    }
    
    void GUI_BOX::SetBoxRect(SMALL_RECT sr)
    {
        srBoxRect = sr;
    
        CalcBoxCorners();
    }
    
    void GUI_BOX::SetBoxRect(int iTop, int iBottom, int iLeft, int iRight)
    {
        srBoxRect.Top = iTop;
        srBoxRect.Bottom = iBottom;
        srBoxRect.Left = iLeft;
        srBoxRect.Right = iRight;
    
        CalcBoxCorners();
    }
    
    void GUI_BOX::CalcBoxCorners()
    {
        cdTopLeft.X = srBoxRect.Left;
        cdTopLeft.Y = srBoxRect.Top;
    
        cdTopRight.X = srBoxRect.Right;
        cdTopRight.Y = srBoxRect.Top;
    
        cdBottomLeft.X = srBoxRect.Left;
        cdBottomLeft.Y = srBoxRect.Bottom;
    
        cdBottomRight.X = srBoxRect.Right;
        cdBottomRight.Y = srBoxRect.Bottom;
    }
    
    
    GUI_BOX::GUI_BOX()
    {
    
    }
    
    //GUI_BOX::GUI_BOX(GUI_BOX gb)
    //{
    //    SetFillColor(gb.GetBoxFillColor());
    //
    //    SetBoxRect(gb.GetBoxRect());
    //
    //    CalcBoxCorners();
    //}
    
    GUI_BOX::GUI_BOX(int iTop, int iBottom, int iLeft, int iRight, GUI_COLOR gcBoarderColor, GUI_COLOR gcFillColor)
    {
        srBoxRect.Top = iTop;
        srBoxRect.Bottom = iBottom;
        srBoxRect.Left = iLeft;
        srBoxRect.Right = iRight;
    
        gcBoxBoarderColor.SetForeColor(gcBoarderColor.GetForeColor());
        gcBoxBoarderColor.SetBackColor(gcBoarderColor.GetBackColor());
    
        gcBoxFillColor.SetForeColor(gcBoarderColor.GetForeColor());
        gcBoxFillColor.SetBackColor(gcBoarderColor.GetBackColor());
    
        CalcBoxCorners();
    }
    
    GUI_BOX::GUI_BOX(SMALL_RECT sr, GUI_COLOR gcBoarderColor, GUI_COLOR gcFillColor)
    {
        srBoxRect = sr;
    
        gcBoxBoarderColor.SetForeColor(gcBoarderColor.GetForeColor());
        gcBoxBoarderColor.SetBackColor(gcBoarderColor.GetBackColor());
    
        gcBoxFillColor.SetForeColor(gcBoarderColor.GetForeColor());
        gcBoxFillColor.SetBackColor(gcBoarderColor.GetBackColor());
    
        CalcBoxCorners();
    }
    
    GUI_BOX::GUI_BOX(int iTop, int iBottom, int iLeft, int iRight, int ibcfc, int ibcbc, int ifcfc, int ifcbc)
    {
        srBoxRect.Top = iTop;
        srBoxRect.Bottom = iBottom;
        srBoxRect.Left = iLeft;
        srBoxRect.Right = iRight;
    
        gcBoxBoarderColor.SetForeColor(ibcfc);
        gcBoxBoarderColor.SetBackColor(ibcbc);
    
        gcBoxFillColor.SetForeColor(ifcfc);
        gcBoxFillColor.SetBackColor(ifcbc);
    
    
        CalcBoxCorners();
    }
    
    GUI_BOX::GUI_BOX(SMALL_RECT sr, int ibcfc, int ibcbc, int ifcfc, int ifcbc)
    {
        srBoxRect = sr;
    
        gcBoxBoarderColor.SetForeColor(ibcfc);
        gcBoxBoarderColor.SetBackColor(ibcbc);
    
        gcBoxFillColor.SetForeColor(ifcfc);
        gcBoxFillColor.SetBackColor(ifcbc);
    
        CalcBoxCorners();
    }
    
    GUI_BOX::~GUI_BOX()
    {
    
    }
    
    #endif // GUI_BOX_H_INCLUDED
    gui_color.cpp
    Code:
    // gui_color.cpp
    #include <windows.h>
    #include <wincon.h>
    
    class GUI_COLOR
    {
        public:
    
            int GetColor();
            int GetForeColor();
            int GetBackColor();
    
            void SetColor(GUI_COLOR);
            void SetForeColor(int);
            void SetBackColor(int);
    
            //GUI_COLOR & operator=(GUI_COLOR &rhs);
    
            GUI_COLOR();
            GUI_COLOR(int, int);
    
            ~GUI_COLOR();
    
        private:
    
            int iForeColor, iBackColor;
    };
    gui_color.h
    Code:
    // gui_color.h
    #ifndef GUI_COLOR_H_INCLUDED
    #define GUI_COLOR_H_INCLUDED
    
    #include "gui_color.cpp"
    
    int GUI_COLOR::GetColor()
    {
        return (iForeColor | iBackColor);
    }
    
    int GUI_COLOR::GetForeColor()
    {
        return iForeColor;
    }
    
    int GUI_COLOR::GetBackColor()
    {
        return iBackColor;
    }
    
    void GUI_COLOR::SetColor(GUI_COLOR gc)
    {
        SetForeColor(gc.GetForeColor());
        SetBackColor(gc.GetBackColor());
    }
    
    void GUI_COLOR::SetForeColor(int ifc)
    {
        iForeColor = ifc;
    }
    
    void GUI_COLOR::SetBackColor(int ibc)
    {
        iBackColor = ibc;
    }
    
    //GUI_COLOR & GUI_COLOR::operator=(GUI_COLOR &rhs)
    //{
    //    if (this != &rhs)
    //    {
    //        return GUI_COLOR(iForeColor + rhs.GetForeColor(), iBackColor + rhs.GetBackColor());
    //    }
    //
    //}
    
    GUI_COLOR::GUI_COLOR()
    {
        iForeColor = 0;
        iBackColor = 0;
    }
    
    GUI_COLOR::GUI_COLOR(int ifc, int ibc)
    {
        iForeColor = ifc;
        iBackColor = ibc;
    }
    
    GUI_COLOR::~GUI_COLOR()
    {
    
    }
    
    #endif // GUI_COLOR_H_INCLUDED

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    Code:
    // gui_color.h
    #ifndef GUI_COLOR_H_INCLUDED
    #define GUI_COLOR_H_INCLUDED
    
    #include "gui_color.cpp"
    Why are you using lines to include source files like this? You should just add them to the project, to my eye it looks like you have things back to front, unless there is some hyper-duper code method going on that i am ignorant of (very likely of course) You need to include the header file in your source file, not the other way around

    Other things seem back to front to, am i just reading this wrong? It looks like you have a load of function definitions in your header files, and a load of function declarations in your source files..!

    Things should be more like this:

    Your header file: (the names GLwin is just chopped from a class i had on screen so means nothing)

    Code:
    #ifndef GLWINDOW_H_INCLUDED
    #define GLWINDOW_H_INCLUDED
    
    //
    //if you need to include other headers / headers of your own
    // include them here!
    
    const int MAX_COLORS 256
    
    class GLwin
    {
    
        public:
        
        int c;
        
        void GetColor();
        
        GLwin();
    
    };
    
    #endif // GLWINDOW_H_INCLUDED
    in your source file GLwin.cpp :

    Code:
    #include "GLwindow.h"
    
    GLwin::GLwin()
    {
        c = 0;
    }
    
    void GLwin::GetColor()
    {
        //...set your color here!
        //eg...
        if(c < MAX_COLORS)
        c++;
        
    }
    In your main file:

    Code:
    //..
    //regular headers
    //...
    
    #include "GLwindow.h"
    
    
    int main()
    {
        GLwin win;
        
        win.GetColor();
        
        return 0;
    }
    Last edited by rogster001; 08-22-2011 at 08:04 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    ok so i tried that and now it says nothing was declared in this scope

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    It says 'nothing' was declared in this scope? I have to ask is this your own code? As i can't see how you got as far as you did, using the type of code you are and are unable to organise your header / source/ declarations etc.

    What is the exact error message? And how did you change your code exactly?
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    as in int GUI_COLOR::GetColor() was not defined in this scope. i went from the way its is in the first post to flipping my .h and .cpp file contents like was suggested. when i did that i went from errors telling me multiple definations of my class methods to having it say none of them were declared. and yes the majority of the code is mine about less than 200 lines of it i found online through tutorials and i changed it as i needed. and what do you mean as far as i did using the code i am. and the part about not being able to organize my headers and sources well high school was awhile ago and it was a pain then too lol.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You did put all your .cpp files in the project, yes? (Or if you are compiling from the command line, you do have them all typed in.)

  7. #7
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    what do you mean as far as i did using the code i am. and the part about not being able to organize my headers and sources well high school was awhile ago and it was a pain then too lol.
    It's just that sometimes people post complex code but are asking very basic questions, - Leads one to think it cannot be mostly their own code... and often the root problems are copypaste syndrome, big chunks of code not properly understood being hoiked into a project and then efforts made to try and 'make it work' .. I am not saying that is what you have done, just that that is how it perhaps would appear, as being able to write that sort of code suggests a knowledge of organising project files and linking.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  8. #8
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    i was thinking about that i was sure they were added and i seen ppl talking about linking and make files but i wasnt quite following it so how do i make sure they are added or link them or what ever im supposed to be doing

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by codebreather View Post
    i was sure they were added
    Based on your posts so far, you're going to have to provide more evidence than that.

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    Well i am inclined to agree with Tabstop, if you have properly fixed up your files then its more than likely you do not have them included in your project build targets or added to the project, thus the compiler cannot know about Foo::FooBar() if it does not know about the Foo header, or conversely it knows the Foo header but cannot find the working parts of the function as they are contained in (foo.cpp) or... or... there are various permutations of the above, but they all come down to the same thing.

    Post your fixed up code since the last edit
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  11. #11
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    heres a screen shot:

    Name:  BuildTargets.jpg
Views: 91
Size:  107.1 KB

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So I see a really broken file: you've got a .h file opened, and yet there is code in it. That shouldn't happen.

    .h files: the declaration of the class

    .cpp files: #include of .h files, code

    Get on it.

  13. #13
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    yeah i changed it back to like it was because when i did what you had said it didnt work but ill try again after i make a phone call

  14. #14
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,422
    yeah i changed it back to like it was because when i did what you had said it didnt work
    And then you posted a screenshot of your code put back exactly as it was to start with except harder to read as it is now in a screengrab, not much point doing that mate, you would be better posting the revision effort you made as requested

    The simplest way for you to figure this out would be to make a back up of what you have now, then strip out as much code as possible, to leave only something like this representing your calss declarations, functions everything:

    try this example and if you get it to link and build then you just need to organise your own in the same way

    Code:
    //Put this in a header called test.h
    
    Class TestClass
    {
        public:
    
        int x;
        void FunctionOne();
        void FunctionTwo();
    
        TestClass();
    };
    
    //put this in a source file called test.cpp
    
    #include <iostream>
    #include test.h
    
    using namespace std;
    
    TestClass::TestClass()
    {
        x = 100;
        cout << "construction" << x << "\n";
    }
    
    void TestClass::FunctionOne()
    {
        cout << "function one" << x << "\n";
    }
    
    void TestClass::FunctionTwo()
    {
        cout << "funbction two" << x << "\n";
    }
    
    //Put this in a main file
    
    #include <iostream>
    #include test.h
    
    using namespace std;
    
    
    int main()
    {
    
        TestClass t;
        t.FunctionOne();
        t.FunctionTwo();
    
        cout << "MAIN" << x << "\n";
    
        return 0;
    }
    Last edited by rogster001; 08-22-2011 at 09:52 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  15. #15
    Registered User
    Join Date
    Jul 2011
    Posts
    10
    the screen shot was so that it could be seen that i add the files added and the error list as well but all that matters is that i did the first suggestion over again and for some reason different than the first time its working now so thanks for the knowledge time and patience i appreciate it.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Defining class methods
    By sand_man in forum C++ Programming
    Replies: 2
    Last Post: 11-01-2005, 05:09 AM
  2. Splitting up class definitions
    By Dunners in forum C++ Programming
    Replies: 4
    Last Post: 02-21-2005, 11:13 AM
  3. Where are class methods in memory?
    By BrownB in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2005, 01:36 AM
  4. Exporting Class methods to a DLL
    By EvBladeRunnervE in forum Windows Programming
    Replies: 2
    Last Post: 12-09-2003, 06:29 PM
  5. Help with methods of a fraction class
    By NebulousMenace in forum C++ Programming
    Replies: 10
    Last Post: 04-01-2003, 11:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21