need help to fix this!

#include <iostream>
#include <iomanip>
using namespace std;

class date
{
public:
date (int=7, int=4,int=2012);
void setdate(int, int, int);
void showdate();
private:
int month;
int day;
int year;
};

void date::date(int mm,int dd,int yyyy)
{
month=mm;
day=dd;
year=yyyy;
};
void date::setdate(int mm, int dd, int yyyy)
{
cout<< "the date is ";
cout<<setfill('O')
<<setw(2)<<month<<'/'
<<setw(2)<<day<<'/'
<<setw(2)<<year%100;
// extract the last 2 year digits
cout<<endl;
return;
}
int main()
{
date a,b,c (4,1,2000);
b.setdate(12,25,2009);
a.showdate();
b.showdate();
c.showdate();
return 0;
}




when write this in visual studio, its says the void in "void date::date(int mm,int dd,int yyyy)" is "return type may not be specified on a constructor." help i dont know what that means, and im a major newb at programming.
Remove the void at the start of it.
a.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\person\documents\visual studio 2010\Projects\homework2\Debug\homework2.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.

the exact errors , i tried taking out the void, but it didnt work :(
Last edited on
This is a completely different error. This is a linker error. That means your code compiled fine. It's complaining about not being able to find the main function.

You should to determine the methods:
1
2
void setdate(int, int, int);
void showdate();


And your method setdate(int, int, int) is illogical.
"setdate()" should set values of members, but not show it.

P.S. sorry for my English)
Last edited on
Did you mean
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
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <iomanip>

using namespace std;

 class date
 {
 public:
    date (int=7, int=4,int=2012);
    void setdate(int, int, int);
    void showdate();
 private:
    int month;
    int day;
    int year;
 };

 date::date(int mm,int dd,int yyyy)
 {
    month=mm;
    day=dd;
    year=yyyy;
 }

 void date::setdate(int mm, int dd, int yyyy)
 {
     month = mm;
     day = dd;
     year = yyyy;
 }

void date::showdate()
{
    cout<< "the date is ";
    cout<<setfill('O')
        <<setw(2)<<month<<'/'
        <<setw(2)<<day<<'/'
        <<setw(2)<<year%100;
    cout<<endl;
 }

 int main()
 {
    date a,b,c (4,1,2000);
    b.setdate(12,25,2009);
    a.showdate();
    b.showdate();
    c.showdate();
    return 0;
 }
Topic archived. No new replies allowed.