+ 1

Is the method the same thing as the object in classes ?

Is it correct in c++ and some other programming languages?

9th Aug 2018, 11:44 AM
Hồng Vĩ
Hồng Vĩ - avatar
1 Answer
+ 8
In C++, an object is an instance of a class. A method is a function which belongs to a class. class A { // a method sayHello() void sayHello() { std::cout << "Hello"; } }; This is a class, A. An instance of class A, is an object of class A. int main() { A obj; // object obj.sayHello(); // calls class method. }
9th Aug 2018, 12:28 PM
Hatsy Rei
Hatsy Rei - avatar