Add static vs non-static | non-stateful vs stateful

This commit is contained in:
Lev
2021-05-24 21:00:30 -05:00
parent a7d5e99475
commit 8eab127c8b
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
#include <string>
#include <iostream>
int main()
{
std::string s = "Matthew";
std::cout << "Length of the string is " << s.length() << std::endl; // .length is stateful
// the life of a stateful function ends with the object that it belongs to
// static or non-stateful function, they use memory and then return it
std::cout << std::stod("100") << std::endl;
}