+ 1
Is the method the same thing as the object in classes ?
Is it correct in c++ and some other programming languages?
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.
}