Hello, i wanted to ask,
How can i use a function (eg std::sort) without including the nessesary header?(in this case <algorithm>)?
And will this help me make a program faster?(like when i want 10 funcitons from 10 different libraries, when i dont include them with the way you will,i guess, show me)
Including a header has no affect on speed, just size of the executable. If you're needing to include 10 headers, to use 1 function from each header, you may want to think about breaking your program up into classes.
How can i use a function (eg std::sort) without including the nessesary header?
You kind of answer this yourself with the word necessary. I guess you could write your own function for it? But I don't really see the purpose of that when they're already written for you :D
I'd like to mention that modern compilers optimize out some functions and variables that aren't used (some can't be optimized out for one reason or another). This means that the impact of unused functions on the size of the final executable is kept pretty minimal. However as Disch mentioned, they will impact the compile time of the project (when you are recompiling the entire project that is).
EDIT: Alternatively in order to literally answer your question, if the function is defined in the header, or a .cpp file, then open it up and copy paste the source code into your project. This violates every license I have ever read including the open source ones but this is about the only way to accomplish what you are asking.