Cpp - Operator sizeof Operator

Introduction

The amount of memory to store an object of a certain type can be returned using the sizeof operator:

sizeof(name) 

It yields the size of an object in bytes, and the parameter name indicates the object type or the object itself.

For example, sizeof(int)represents a value of 2 or 4 depending on the machine.

sizeof(float) will always equal 4.

Classification

The fundamental types in C++ are integer types, floating-point types, and the void type.

The types used for integers and floating-point numbers are collectively referred to as arithmetic types.

You can use arithmetic operators on them.

The void type is used for expressions that do not represent a value.

A function call can thus take a void type.

Exercise