Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

People also ask

What is free function in C?

C library function - free() The C library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc.

What do you mean by free function?

The free() function in C++ deallocates a block of memory previously allocated using calloc, malloc or realloc functions, making it available for further allocations. The free() function does not change the value of the pointer, that is it still points to the same memory location.

What is free and realloc in C?

free() deallocate the previously allocated space. realloc() Change the size of previously allocated space.

What is free memory in C?

It means that whenever you declare a regular variable of any data type in C, the programming language itself is responsible for deallocating or releasing this memory once your program has been executed successfully.


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