Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ trouble understanding debug report

Name: Anonymous 2012-03-14 22:26

I have revised my code.

Main.cpp
#pragma once //if something is #included more than once, the extras are ignored.

#include "Window.cpp"
#include <iostream>
#include <stdlib.h>

using namespace std;

int main ()
{
    int Choice = 0;

    do
    {
        cout << "  ----menu----\n" << endl;
        cout << "1:---window---" << endl;
        cout << "2:---tvshow---" << endl;
        cout << "3:--mychoice--" << endl;
        cout << "4:----quit----\n" << endl;
        cout << "Please choose: ";

        cin >> Choice;

        switch (Choice)
        {
            default:
                Choice = 0; break;
            case 1:
                Winmain(); break;
            case 2:
                cout << "\nunavailable..\n\n" << endl; break;
            case 3:
                cout << "\nunavailable..\n\n" << endl; break;
            case 4:
                cout << "\nGoodbye!" << endl; break;
        }
    }while (Choice !=4);
return 0;
}


Window.cpp
#include <iostream>
#include <stdlib.h>
#include "Window.h"
#include <string>
using namespace std;

int Retrn = 0;

void Winmain()
{
    int Choice = -1;
    int Input = 0;
    string InputString = 0;
    Window Win1;

    do
    {
        cout << "\n\n-Window CPP-\n\n";
        switch (Choice)
        {
            default:
                break;

            case -1:
                cout << "\nHow wide is the window: ";
                cin >> Input;
                Win1.getXpos(Input);
                Choice = Retrn;
                break;

            case -2:
                cout << "\nHow tall is the window: ";
                cin >> Input;
                Win1.getYpos(Input);
                Choice = Retrn;
                break;

            case -3:
                cout << "\nWhat application is running within the window: ";
                cin >> InputString;
                Win1.getWinname(InputString);
                Choice = Retrn;
                break;

            case -4:
                cout << "\nZ is running in a X x Y window.";
                break;
        }
    }while (Choice !=-4);
}

void Window::getXpos (int getX)
{
    Retrn = setXpos(getX);
}

int Window::setXpos(int setX)
{
    if ((setX < 1) || (setX > 1920))
    {
        xposition = setX;
        return -2;
    }
    else
        return -1;
}

void Window::getYpos (int getY)
{
    Retrn = setYpos(getY);
}

int Window::setYpos(int setY)
{
    if ((setY < 1) || (setY > 1920))
    {
        yposition = setY;
        return -3;
    }
    else
        return -2;
}

void Window::getWinname (string getWin)
{
    setWinname(getWin);
}

int Window::setWinname(string setWin)
{
    if (setWin > "")
    {
        winname = setWin;
        return -4;
    }
    else
        return -3;
}


Window.h
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;

class Window
{
    //Variables
    int xposition, yposition;
    string winname;
   
    //3 set member functions
    int setXpos (int);
    int setYpos (int);
    int setWinname (string);

    //toString method
    //void toString ();

public:

    //3 get member functions
    void getXpos (int);
    void getYpos (int);
    void getWinname (string);
};


Debug returns this:
[output]1>------ Build started: Project: cppProj1, Configuration: Debug Win32 ------
1>  Window.cpp
1>  Main.cpp
1>  Generating Code...
1>Window.obj : error LNK2005: "void __cdecl Winmain(void)" (?Winmain@@YAXXZ) already defined in Main.obj
1>Window.obj : error LNK2005: "public: void __thiscall Window::getXpos(int)" (?getXpos@Window@@QAEXH@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "private: int __thiscall Window::setXpos(int)" (?setXpos@Window@@AAEHH@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "public: void __thiscall Window::getYpos(int)" (?getYpos@Window@@QAEXH@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "private: int __thiscall Window::setYpos(int)" (?setYpos@Window@@AAEHH@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "public: void __thiscall Window::getWinname(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getWinname@Window@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "private: int __thiscall Window::setWinname(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setWinname@Window@@AAEHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in Main.obj
1>Window.obj : error LNK2005: "int Retrn" (?Retrn@@3HA) already defined in Main.obj
1>G:\Ferg\Projects\cppProj1\Debug\cppProj1.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/output]

I don't understand what could be wrong, any and all help is again greatly appreciated!

Name: Anonymous 2012-03-14 22:35

Change #include "Window.cpp" to #include "Window.h"

Name: Anonymous 2012-03-14 22:38

Name: Anonymous 2012-03-14 22:42

>>2
it says there's no such file or directory wat do i do halp pl0x

Name: Anonymous 2012-03-14 22:45

>>4
probably try another language that doesnt require any learning
think that should fix your problem

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List