I have a class with a member function called factorial. I want that function to be available without an instance of the class being around (the class is initialized to eat up a lot of space, and initialization takes time). I am trying something like the code below, but it doesn't work. Does anyone have ideas?
wrapper.cpp: In function 'int main()':
wrapper.cpp:18: error: invalid use of non-static member function 'long double prob_vector::factorial(long double)'
Absolute beginner here, so please dumb down your comments :-)
It means that you can use the member function without defining the class. However if you need to save any of the data in private members of the class this won't work because by not defining an object of that class, you haven't allocated any space for those private members.
Static member functions are useful in cases like this: