Return of int

This is a simply program for date but i don't understand why it shows this errors
main.cpp
1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
#iclude"Date.h"
using namespace std;
void main (){
	
	int  y;
	
	Date today(17, 11, 2018);
	y =today.Day;//Why this doesn't work?
	cout <<y;
}

Date.h
1
2
3
4
5
6
7
8
9
10
11
12
class Date
{
	int day;
	int month;
	int year;
public:
	Date(int x, int y, int z);
	 int Day(int x) { return day; }
	 int Month(int x)  { return month; }
	 int Year(int x) { return year; }



1
2
3
4
5
6
7
8
9
10
#include"Date.h"


Date::Date(int x, int y, int z)
{
	day = x;//Not checking anything,most simplest way
	month = y;
	year = z;

}

State
Error C3867 'Date::Day': non-standard syntax; use '&' to create a pointer to member What does this mean?
Severity Code Description Project File Line Suppression State
Error C2440 '=': cannot convert from 'int (__thiscall Date::* )(void)' to 'int' and this error



y =today.Day;//Why this doesn't work?

It doesn't work because that's not how to call a function. This is:
y =today.Day();
Thank you very much for the answer.
change the code
1
2
3
int Day(int x) { return day; }
int Month(int x)  { return month; }
int Year(int x) { return year; }

to
1
2
3
int Day() { return day; }
int Month()  { return month; }
int Year() { return year; }


and call the function using
y =today.Day();

In addition, you'd better not use void main()in C++, butint main().
Topic archived. No new replies allowed.