1. vector Vector is a sequence container that supports dynamic size changes. It is a part of Standard Template Library (STL) in C++. It can be used to store a collection of elements (int, char, etc.) and provides constant time complexity for accessing its elements.
Example code:
#include
int main() { std::vector myvector; // declare a vector of integers myvector.push_back(1); // add an element to the end myvector.push_back(2); myvector.push_back(3); return 0; }
Package/library: Standard Template Library (STL)
2. string String is a data type that represents a sequence of characters. It is commonly used in C++ for storing and manipulating text. It has various member functions that allow you to manipulate the string, like concatenation, substring, etc.
Example code:
#include
int main() { std::string mystring = "Hello world!"; // declare a string std::string substring = mystring.substr(0, 5); // get a substring from index 0 to 5 std::string joined = mystring + " Welcome!"; // concatenate a string return 0; }
Package/library: Standard Template Library (STL)
3. bool Bool is a data type that represents a Boolean value, which can be either true or false. It is often used in C++ for conditional statements, comparison operations, and logical operations.
Example code:
bool mybool = true; if (mybool) { // do something if mybool is true }
Package/library: Standard C++ library
4. int Int is a data type that represents an integer value. It is commonly used in C++ for mathematical operations, indexing, and counting.
Example code:
int sum = 0; for (int i = 1; i <= 10; i++) { sum += i; // add i to sum }
Package/library: Standard C++ library
5. float Float is a data type that represents a floating-point number. It is commonly used in C++ for mathematical operations that require decimal precision, like scientific calculations and simulations.
Example code:
float pi = 3.14159265358979323846; float radius = 5.0; float area = pi * radius * radius;
Package/library: Standard C++ library.
C++ (Cpp) DataType::kind - 28 examples found. These are the top rated real world C++ (Cpp) examples of DataType::kind from package IntegraLive extracted from open source projects. You can rate examples to help us improve the quality of examples.