What is the meaning of the term "free function" in C++?

While reading the documentation for boost::test, I came across the term "free function". What I understand is that a free function is any function that doesn't return anything (Its return type is void). But after reading further it seems that free functions also don't take any arguments. But I am not sure. These all are my assumptions. So could anybody define free function?

1 Answer

The term free function in C++ simply refers to non-member functions. Every function that is not a member function is a free function.

struct X { void f() {} // not a free function
};
void g() {} // free function
int h(int, int) { return 1; } // also a free function
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like