-
August 30th, 2009, 02:01 PM
#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
-
August 30th, 2009, 07:26 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|