Include a specific function from the header file in code in C ++

In python, you can import certain sets of functions from different modules, rather than import the whole file

Example:

Instead of using import mathand using print math.sqrt(4), importing the function directly:

from math import sqrt
print sqrt(4)

And it works great.


Where, as in Cand 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?

+1
source
1

, . ++ , . ++ 11. . ++ Modules - ++ 0x? ? .

, - . / , . ?

+3

Source: https://habr.com/ru/post/1687243/


All Articles