forked from Bhupesh-V/30-seconds-of-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added code to depict use of set.size()
- Loading branch information
1 parent
4b2e94b
commit c1a787a
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# size | ||
|
||
**Description :** | ||
This method is used to return the size of set. The return type is size_t (quite similar to unsigned integer), which overflows when a bigger number is subtracted from it. | ||
|
||
**Example :** | ||
```cpp | ||
//Run Code To Demonstrate use of set.size() | ||
#include<iostream> | ||
#include<set> | ||
|
||
int main(){ | ||
// Create a set object holding integers | ||
std::set<int> mySet {1,2,3,4,-5}; | ||
|
||
std::cout << "Size of my set is : " << mySet.size() << std::endl; | ||
|
||
return 0; | ||
} | ||
|
||
``` | ||
|
||
**[Run Code](https://ideone.com/guEojH)** |