answersLogoWhite

0

Data types specify how data is interpreted. All data in a binary computer is stored as a sequence of bits (binary digits), thus all data is represented by numeric values. The data type associated with that data determines how many bits the data occupies and how that data should be interpreted. For instance, an unsigned char data type occupies 8 bits (1 byte) which translate to a numeric value in the range 0 to 255. These values map to ASCII character codes in the current code page, thus if you were to output a char data type it would print the character associated with the character code rather than the numeric value of the code. Unicode character codes use 16 bits (2 bytes) to represent each character and are therefore unsigned short types, also known as wchar_t types.

The primitive data types include int, short and char, which are all integral data types used to store integers (whole numbers). Each may be further qualified with the signed or unsigned keywords, thus a signed char will represent values in the range -128 to +127.

Strings of characters are represented as an array of char types, typically terminated by a null character which has the value 0. Arrays are simply sequence containers containing one or more data elements of the same type. Since the length of each element is the same, it is trivial to locate any element within the array given the element's index where the first element can be found at index 0. Thus an array of n elements will have indices in the range 0 to n-1. Knowing the size of each element (as determined by its type) means that element x can be found at the memory address x*sizeof(element) bytes from the start of the array, using nothing more than simple pointer arithmetic. However, when you declare an array, the subscript operator can be used to specify the index of the element you wish to examine, while C++ does the pointer arithmetic in the background.

More complex data types can be declared using class or struct keywords. The declaration of these types determines how they are mapped in memory and ultimately how they are interpreted. Primitive data types act as the building blocks for these complex data types, but more complex data types can be composed from any combination of primitive and pre-existing complex data types to produce ever more highly complex data types.

Instances of a type are known as variables or constants, depending on whether the value of the instance can be changed or not. If the type is a complex data type, such as a class or struct, the instance is known as an object, which can also be variable or constant. Many new users regard classes and objects as being the same thing, however a class is the definition of a type while an object is an instance of the type, in the same way that a char is a type while a char variable is an instance of the type.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

What are the two types of constant in c plus plus?

Constant data and constant functions.


Why c plus plus called as paritial oop?

C++ is only partially OOP because it is a superset of C and, for the sake of backward compatibility, retains the concept of primitive data types (such as integrals like char and int) and pointer data types, which are all strictly non-object-oriented. In Java and C#, there is no concept of a primitive data type. Even integral types such as int are treated as objects and there is no concept of a pointer data type.


When do we use int in c plus plus programming?

'int' is one of the built-in data-types, it is meant to hold integer values.


What is the difference between class data type and basic type in c plus plus .How can someone know which one is class type and which one is basic type.?

Basic types (primitive data types) have no methods associated with them.


Describe the four basic data types in c?

Describe the basic data types in C Describe the basic data types in C


What is object oriented in c plus plus?

Object-oriented programming is a feature in C++ that allows you to better model real-world objects. An object is an instance of a class, which is a data structure in C++ that allows you to group different, but related types of data together.


What is datatype.Define various types of data types?

In c language data types are used to specify the tye of data.for ex:int a;It means "a" is a variable of type integer.There are two types of data types in c.They areprimary data typessecondary data typesprimary data types are the built in data types and secondary data types are the user defined data types.eg for primary data types are int,float,char,long,double..and for secondary are arrays,structures,pointers,unions..


Is c plus plus an object oriented language or an object based language?

C++ is object-oriented. It is not object-based because, like C before it, C++ supports the principal of primitive data types, which are not object-based.


What is the range of data types in C programming language?

The ranges for all data types in C are implementation-defined.


User defined data type in c plus plus?

Use "typedef" : both in C and C++.


Basic structure of c n c plus plus?

The basic structure of a C or C++ program is built around types. A structure is a type. A function is a type. A class is a type. All of these types can be built from primitive (built-in) types and can be used to create ever-more complex types.


Do I need types of design patterns in c plus plus?

No.