In python, you can import certain sets of functions from different modules, rather than import the whole file
Example:
Instead of using import math
and using print math.sqrt(4)
, importing the function directly:
from math import sqrt
print sqrt(4)
And it works great.
Where, as in C
and C++
, you need to include the entire header file in order to be able to use only one function that it provides. For example, in C ++
#include<iostream>
#include<cmath>
int main(){
cout<<sqrt(4);
return 0;
}
C
the code will also be similar (not the same).
Is it possible that, as in the case of python, you can include only one function from the header file in your program?
ex: including only the function sqrt()
from cmath
?
It can be done?
source