a namespace statement you won't have to use the std:: prefix Instead of doing these actions as separate steps, you can combine them by initializing the variable and finally printing the result: // a header file that enables the use of functions for outputing information You can then give the variable you created a value, like so: #include Lastly, don't forget the semicolon to end the statement! #include This will let the compiler know what kind of values the variable can store and therefore what actions it can take. To declare an int variable in C++ you need to first write the data type of the variable – int in this case. How to declare and initialize ints in C++ bool, for boolean values (true or false)Ĭ++ is a strongly typed programming language, meaning that when you create a variable you have to explicitely declare what type of value will be stored in it.string, for a sequence of characters (for example 'Hello').char, for single characters (for example 'D', '!').double, for floating point numbers (for example 5.0, 4.5).int, for integer (whole) numbers (for example 10, 150).The C++ programming language has a few built-in data types: In this article you'll learn how to convert a string to an integer in C++ by seeing two of the most popular ways to do so. When you're coding in C++, there will often be times when you'll want to convert one data type to a different one.