answersLogoWhite

0

What is data type in c plus plus?

Updated: 8/11/2023
User Avatar

Wiki User

10y ago

Best Answer

A data type simply means the type of data represented by a variable or constant, or the return type of a function. C++ is a strongly-typed language thus all variables and constants must have a data type associated with them. The data type may be a primitive data type such as int or char, which are used as the building blocks for more complex data types. Primitives, typedefs, enums and classes (which includes structs and unions), are used to provide the definitions for all the various data types that you can employ within a program. Variables and constants provide instances of those data types. Pointer variables must also have a data type associated with them to determine the type of data being referred to, even if it is void* which simply means it points to any data type, the actual data type being determined at runtime. However, in C++, void* is rarely required since polymorphism allows programmers to treat objects generically; there is rarely a need to know the actual runtime type of an object, since that information is provided automatically by the object's own virtual table. The programmer need only know the generic data type and call the appropriate virtual methods of that type in order to invoke the specific behaviour of the actual data type.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

A data type (or simply type) is an identifier (either a reserved word or keyword, or an user-defined identifier) that determines how much memory is allocated to an instance of the type and how that memory is both organised and interpreted. User-defined types build upon the primitive, built-in data types such as char, short, long, float and double, to produce new data types, which can themselves be combined to build yet more complex data types. The typedef, struct, class and union keywords are used to define new data types, each of which is identified by an user-defined name, the type itself. In addition to the primitive data types, the C++ standard template library (STL) also provides several built-in, complex data types including vector, map and list, which can themselves be used to produce more complex user-defined data types.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A data type is a classification specifying one of various type of data.

there are mainly 3 types of data types in C -

Primary or inbuilt data types e.g. int, char, float, double.

derived data types e.g. arrays, pointers.

user defined data type e.g. structure,union

This answer is:
User Avatar

User Avatar

Wiki User

7y ago
C++ has a set of fundamental types corresponding to the most common basic storage units of a computer and the most common ways of using them to hold data.
  • A Boolean type (bool).
  • Character types (such as char and wchar_t).
  • Integer types (such as int and long long).
  • Floating-point types (such as float and long double).
  • A type, void, used to signify the absence of information.

From these types, we can construct other types using declarator operators:

  • Pointer types (such as int*).
  • Array types (such as char[]).
  • Reference types (such as double& and vector&&).


In addition, a user can define additional types:

  • Data structures and classes (union, struct and class).
  • Enumeration types for representing specific sets of values (enum and enum class).


The Boolean, character and integer types are collectively called integral types. The integral and floating-point types are collectively called arithmetic types. Enumerations and classes are called user-defined types because they must be defined by users rather than being available for use without previous declaration, the way fundamental types are. In contrast, fundamental types, pointers and references are collectively referred to as built-in types. The standard library provides many user-defined types.

The Integral and floating-point types are provided in a variety of sizes to give the programmer a choice of the amount of storage consumed, the precision, and the range available for computations. The assumption is that a computer provides bytes for holding characters, words for holding and computing integer values, some entity most suitable for floating-point computations, and addresses for referring to those entities. The C++ fundamental types together with pointers and arrays present these machine-level notions to the programmer in a reasonably implementation-independent manner.

For most applications, we could use bool for logical values, char for characters, int for integer values and double for floating-point values. The remaining fundamental types are variations for optimisations, special needs and compatibility that are best ignored until such needs arise.

Source: The C++ Programming Language, Fourth Edition (Bjarne Stroustrup).
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is data type in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

User defined data type in c plus plus?

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


Can an integer data type in c plus plus stores character value?

no


What use of void data type in c plus plus?

doesn't return the value.


What is difference between '1' and 1 as for us a computer is concerned with respect to c plus plus?

When you type '1' in a C++ program, it is considered to be of character data type(char). When you type 1, it is considered to be of integer data type.


What are logical classes in c plus plus?

There is no such thing. Logic is bitwise operation, not a data type.


What Lead to C C plus plus and java?

(C and Lisp, ... data type") was adopted by many later languages, such as ALGOL 68 (1970), Java, and C#. ... C++ has a separate Boolean data type ( 'bool' ), but with automatic conversions from ... "Report on the Algorithmic Language ALGOL 68


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.


Defference between c plus plus and c?

these are difference in between c and c++: a) C is a SPL and C++ is a OOP. b) C has not concept of object but C++ has this feature. c) C has not 'class' name data type but C++ has.


What is different between primitive date type and non primitive data type in c plus plus programming language?

A primitive data type is built into the language - int, char, long, etc. A non-primitive data type is am abstract data type that is built out of primitive data types - linked list, queue, stack, etc.


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.


What is the c plus plus command to read a line?

You can use cin which located in iostream.h You have to use certain data type to read string, for instance, array of char


What does tbuffer mean in c plus plus?

There is no such keyword or data type known as tbuffer in C++. It's most likely an user-defined identifier, possibly a text buffer. But without knowing its actual type or its context it's impossible to say what it means.