CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    I am having problems compiling and running this program

    This is what i wrote:

    #ifndef EMPLOYEE_TYPE_FLAG
    #define EMPLOYEE_TYPE_FLAG

    #include <iostream>
    using namespace std;



    struct employee_type
    {
    char ssn[10];


    employee_type()
    {
    ssn[0]='\0';
    }

    bool operator > (employee_type &e)
    {
    return strncmp(this->ssn, e.ssn, 10) >0;
    }
    bool operator < (employee_type &e)
    {
    return strncmp(this->ssn, e.ssn, 10) <0;
    }
    bool operator >= (employee_type &e)
    {
    return strncmp(this->ssn, e.ssn, 10) >=0;
    }

    bool operator <= (employee_type &e)
    {
    return strncmp(this->ssn, e.ssn, 10) <=0;
    }
    bool operator != (employee_type &e)
    {
    return strncmp(this->ssn, e.ssn, 10) !=0;
    }

    employee_type &operator = (employee_type &e)
    {
    strncpy(this->ssn, e.ssn, 10);
    return *this;
    }

    friend ostream &operator<<(ostream &os, employee_type &e)
    {
    os<<e.ssn<<'\n';
    return os;
    }

    int main()
    {
    cout << "Test" << endl;
    }
    };
    #endif

    I am getting "id returned1 exit status. Can anyone help

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: I am having problems compiling and running this program

    Please use code tags to format your code.

    Your program gave me this linker error in Visual Studio:
    Code:
    Error	2	error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup	MSVCRTD.lib
    This is because main can't be inside a struct like that; it has to be a free function. Move main outside of the employee_type struct and preferably into its own file.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured