i make this program but its not running why..

October 6, 2010 at 01:43:49
Specs: Windows XP
its my header file:
#include<iostream.h>
#include<stdafx.h>
class Date
{
private:
int day;
int month;
int year;
public:
Date();
Date(int ,int);
Date(int ,int,int);
~Date();
void setDate();
void setMonth();
void setYear();
void display();


int getDay();
int getMonth();
int getYear();

}
its header file implementation
#include<iostream.h>
#include"print.h"

Date::Date()
{
day=1;
month=11;
year=2010;
cout<<"the default construcor called"<<endl;
}
Date::Date(int theDay, int theMonth)
{
day= theDay;
month=theMonth;
year=1996;
cout<<"parameterized constructor called"<<endl;
}
Date::Date(int theDay, int theMonth, int theYear)
{
day= theDay;
month= theMonth;
year= theYear;
cout<<"three parameterized construcot called"<<endl;

}
Date::~Date()
{
cout<<"the object has been destroed"<<endl;
}
void Date::setDay(int i)
{
day=i;

}
void Date::setMonth(int i)
{
month=i;

}
void Date::setYear()
{
year=i;
}
int Date::getDay()
{
return day;
}
int Date::getMonth()
{
return month;
}
int Date::getYear()
{
return year;
}
void Date::display()
{
cout<<"the date is"<<getDay()<<getMonth()<<getYear();
}
and finally its my main function
#include<iostream.h>
#include<stdafx.h>
#include "print.h"
int main()
{
Date date1, date2(10,11);

date1.display();
date2.display();
}

but in rebuilt solution its give two error... can anybody help me to solve this problem that where i am doing mistake...

i will he thanksfull to you all

Thnaks!


See More: i make this program but its not running why..

Report •

#1
October 6, 2010 at 07:19:09
If you were to tell us what the errors are there would be a far greater chance of someone telling you what the problem is. If you told us what you are expecting the programme to achieve that would help as well.

The only other way is for someone to compile programme and see if they get the same errors as you. Too time consuming when the errors are already know by someone else.

Stuart


Report •

#2
October 7, 2010 at 01:08:05
Just a quick looksy; if you're having redifinition type errors, try using a macro guard - it looks like you've got multiple instances of #include <various_headers>.

You could create a constructor using default arguments

Date::Date(const int &m = 10, const int &d = 1, const int &y = 2010) {
month = m; day = d; year = y;
}

Date d1, d2(10), d3(1, 1), d4(6, 10, 1900);

With your setMonth, setDay, and setYear member functions, you seem to be lacking a parameter list.

With the display() member function, you have access to the private data members; you wouldn't need to call other member functions to output the month, day, and year.

HTH

-------------------------------------------
I have no aspiration for preaching. ;-)


Report •
Related Solutions


Ask Question