In python, one can import specific feature-sets from different modules, rather than importing the whole file
ex:
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 just fine.
Where as in C
and C++
, one has to include the whole header file to be able to use just one function that it provides. Such as, in C++
#include<iostream>
#include<cmath>
int main(){
cout<<sqrt(4);
return 0;
}
C
code will also be similar (not same).
Is it possible that just like as it was in case of python, one can include just one function from a header file into their program?
ex: including just the sqrt()
function from cmath
?
Could it be done?