method and property on OOP?

hey guys, can you explain to me what method and property on OOP is? i search it on google, but still have no idea. can you explain it to me with the example of the program? thank you :)
Last edited on
Hi

A method is a class function, a property is a class member variable.
For example:

1
2
3
4
5
6
7

class Obj {
    public:
        int getNumber(); //method or class function

    private:
        int number //property or member variable 


PS: If you don't understand 'public' and 'private' just ignore them
Last edited on
closed account (zb0S216C)
C++ has no "methods", nor does it have "properties". In C++, they are called member functions and data members respectively. A member function is a function that's associated with a class. A data member is a variable/object that is also associated with a class. In order to access either a member function or a data member, you need an object; that is, an instantiation of a class.

Wazzak
Last edited on
Topic archived. No new replies allowed.