C++ Programming: Objects, RAII and the STL · C++ Basics
Print with cout and <<, end lines with endl, and show true/false with boolalpha.
#include <iostream>
using namespace std;
int main() {
int apples = 3;
double price = 0.5;
bool fresh = true;
cout << "Apples: " << apples << endl;
cout << "Cost: " << apples * price << endl;
cout << boolalpha << "Fresh? " << fresh << endl;
return 0;
}price is created on the stack with the value 0.5.fresh is created on the stack with the value true.0.