member variables vs member functions

I seriously do not know what the difference is, could anybody please provide a sample as to what a member variable is and what a member function is?

Thank you so much in advance!
A member function is a function that is part of a class.

A member variable is a variable (an object) that is part of a class.

1
2
3
4
5
6
7
class Class
{
public:
	void memberFunction();
private:
	int memberVariable;
};
Last edited on
Thank you so much for responding Peter!

So, just to clarify, according to the definition then, something like (below) would be following my teacher's guidelines ? (she said we can only have three member variables)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Date
{
private:
int day,month,year ;

public:



Date operator//
Date operator//

friend ostream &operator//
friend istream &operator//
Date() //
Date//
void blabla//
int getDate() //
bool operator //
bool operator //
};

Last edited on
Yes, your Date class has three member variables day, month and year.
Thank you very much for the help, you cleared up my confusion over this definition (and now I can turn in this project finally..)

I hope you have a nice day / night !!
Topic archived. No new replies allowed.