What leads to 'error: cannot call member function without object' in c++?
Example:
class MyClass {
void myFunction() {}
};
int main() {
myFunction();
}
You're attempting to call a member function without an instance of the class.
Solution:Create an instance of the class and call the member function on it.
MyClass obj;
obj.myFunction();