Calling functions from class (E2294)

Hi, I am learning C++ and can't understand what I am doing here wrong, I know that my class is like a function because i have used constructor but don't know how i call functions from inside this class because of it now.

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
#include <iostream>

using namespace std;

class datas {
public:
	int test_day;
	int last_day;

	datas(void);

	void setdata(int, int);

	bool check(int day, int check) {
		return (day == check ? 1 : 0);
	};

};

void datas::setdata(int x, int y) {

	test_day = x;
	last_day = y;

}

datas::datas(void) {
	test_day = 0;
	last_day = 0;
}

int main() {

	datas data1(); //EDIT: SHOULD BE WITHOUT PARENTHESES.

	data1.setdata(2, 3); // HERE I GET ERROR

	return 0;
}
Last edited on
The actual problem is actually on the line previous to where you're indicating (Line 34). You need to remove the parentheses from that line and then the program should compile.

I can't create new object without this parentheses because I used my own constructor which forces me to use parenthesis.

EDIT, Sorry, you where right! :) Thank You very much for Your time.
Last edited on
Topic archived. No new replies allowed.