+ 6
What's the difference between a library and function?
I have been seeing these words on my guide but don't have a clear understanding. If possible please provide examples
4 ответов
+ 4
@chirag answer is wrong.
a function is a set of instructions that can be executed by calling the function, example:
int sum(int a, int b) {
return a+b;
}
main () {
cout<<sum(5,3); //outputs 8
}
A library is usually a set of classes and functions that are made by other people to make your like easier, for example c++ comes with the standard library which contains classes for input and output, data stream, containers and orther utilities. There are also third-party libraries like the boost library or sfml
+ 3
@Chirag meaning libraries act as a container of functions?
+ 2
@Marco thanks I now fully have an idea
0
Functions are meant to do a specific task.
Libraries contain the predefined functions provided by the programming language.