using void print()

Hello All,
I am attempting to write a program that takes a month, day and year and outputs the date in athe format Day/Month/Year...
I think I am close and dont have any errors but it may be the order I am listing my code in thats not making it work...
#include <iostream>
using namespace std;

class Date

void setDay (int d);
void setMonth (int m);
void setYear (int y);
void print();

int day;
int month;
int year;


day = month = year = 1;

void Date::setDay (int d)
day = d;
void Date::setMonth (int m)
month = m;
void Date::setYear (int y)
year = y;
void Date::print()
cout << day << "/" << month << "/" << year << endl;

int main()


int m;
int d;
int y;
int day;
int month;
int year;

cout<<"\n Enter the month: ";
cout<<"\n Enter the day: ";
cout<<"\n Enter the year: ";

void print (Date);

return 0;


void print (Date);
You're trying to call a function that doesn't exist.

Here is how to use class functions:

1) Create an instance of the class. For example,
Date anInstance;
2) Call that instance's class function. For example,
Last edited on
you created a class Date but you're not doing anything with it. all you did was input your m, d, y, but did nothing to create an instance of Date or call its setters to pass the value.
Also, your print method should be called like this:

//Date myDate;
Thank you!
that's what I had been missing.
Topic archived. No new replies allowed.