answersLogoWhite

0


Best Answer

C++ provides the following fundamental types:

  • A Boolean type (bool)
  • Character types (char and wchar_t)
  • Integer types (int, short, long and long long)
  • Floating-point types (float, double and long double)
  • A type, void, used to signify the absence of information.

Fundamental types correspond to the basic storage units of the machine. From the fundamental 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 char&&)

The Boolean, character and integer types are collectively known as the integral types. The integral and floating-point types are collectively known as the arithmetic types.

The fundamental types, pointers, arrays and references are collectively known as the built-in types.

The integral types can be further modified using the signed or unsigned modifiers. Strictly speaking, both long and short are also type modifiers because a short implies a short int. This is simply an artefact from C Programming where int was implied in the absence of an explicit type.

Note that aliases (using x = type) and type definitions (typedef) are not types per se, they are simply alternative names for preexisting types. For instance, although wchar_t is a built-in type because it does not require a declaration, in reality it is just an alias for an implementation-defined integral type (typically unsigned short).

From these built-in types we can construct other types:

  • Data structures and classes (such as std::vector and std::string)
  • Enumeration types (enum and enum class)

Data structures, classes and enumeration types are collectively known as user-defined types.

In essence, any type that requires an explicit declaration is a user-defined type. This includes all C++ standard library types such as std::string because we cannot use a std::string object unless we include the header where the type is declared.

User Avatar

Wiki User

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

Wiki User

10y ago

An user-defined type in C++ is any type that is not a primitive or predefined type, including those provided by the standard library. Typically, a user-defined type is a class or union, but you can also define types based upon primitive types in order to simplify your code. For instance, rather than constantly having to write unsigned long long for a 64-bit unsigned value, you could reduce this to an user-defined type, such as uint64, simply by definining the type:

typedef unsigned long long uint64;

Now you can use the user-defined type uint64 everywhere you would have previously used unsigned long long. You've not actually changed the behaviour of the type, you've simply reduced a more complex definition to a much simpler, shorter one.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Any data type that is defined by the programmer. That is, any data type that is not built-in, including user-defined classes and structures.

// int is a built-in type.

// UINT is a user-defined type for an unsigned integer.

typedef unsigned int UINT;

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

It makes the programming both simpler and more natural. For example, if you have a data type for "date" (assuming the language doesn't support this data type natively), you can pass a "date" as a single parameter to a function/method. Also, the function/method can return a date (note that in most languages, a function or equivalent can only return a single value).

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

user can create his own data type for handling data that does not fit in one of the existing data types

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Any type that is not a primitive or is not a pre-defined type is a user-defined type.

typedef unsigned long long UINT64; // user-defined unsigned 64-bit type.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

classes are user define data types and behave like built-in types of a programming language

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

User Define Data type is created by user requirement ,user code.Simply say those data type created by user thats called is user define datatype

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Show me the data types and I do stand a chance of answering your question. You show me nothing so you get a nothing answer.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: User defined data types in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the difference between basic data types and derived data types and user defined data types in C plus plus?

By basic types you presumably mean primitive types or built-in types. These include char, int, long, short, wchar_t, float, double and bool, amongst others. Most are simply variations of each other, but their lengths are implementation dependant. The only exception is char which is always 1 byte in length. User-defined types are those you yourself define or are defined for you. These include typedefs, enums, classes, structs and unions, but can also include some implementation-specific built-in types and all third-party types. Regardless, all user-defined types build upon the primitive data types or other user-defined types. In the case of class and struct types, methods (or member functions) can be associated with those types, thus combining data and the specific methods that act upon that data into a single entity. Objects are specific instances of a class or struct. A derived type is a class (or struct) which inherits from another class (or struct). A derivative cannot inherit from a primitive, enum or union. Derived types are also, by definition, user-defined types.


Define objects and show how they act as user defined data type in c plus plus with the help of a programme?

An object is an instance of a class. A class is a data type that combines data and the specific methods that operate upon that data into a self-contained entity. To prove that objects are user-defined types, consider the following: class foo { }; int main() { foo a; foo b; foo c = a + b; // ERROR! } The reason there is an error is because the plus operator (+) only works with primitive data types (integral, arithmetic and built-in data types). foo is neither an integral, arithmetic nor built-in data type, thus the plus operator is not supported. However, if you provide a user-defined plus operator overload (foo::operator+) that accepts a constant reference to a foo object, the code will compile. It's up to you, the class designer, to provide the appropriate implementation.


Can a C plus plus user defined function return a value?

Absolutely. Indeed, any function (user-defined or built-in) that does not return a value is not really a function, it is simply a procedure.


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.


How do the IO facilities in C plus plus differ from those in C?

The C standard library IO facilities are not extensible. For instance, the printf() and scanf() functions cannot handle user-defined types. However, the C++ standard library provides IO streams with insertion and extraction operators (<< and >>) that can be overloaded to support any user-defined type.

Related questions

What is the difference between basic data types and derived data types and user defined data types in C plus plus?

By basic types you presumably mean primitive types or built-in types. These include char, int, long, short, wchar_t, float, double and bool, amongst others. Most are simply variations of each other, but their lengths are implementation dependant. The only exception is char which is always 1 byte in length. User-defined types are those you yourself define or are defined for you. These include typedefs, enums, classes, structs and unions, but can also include some implementation-specific built-in types and all third-party types. Regardless, all user-defined types build upon the primitive data types or other user-defined types. In the case of class and struct types, methods (or member functions) can be associated with those types, thus combining data and the specific methods that act upon that data into a single entity. Objects are specific instances of a class or struct. A derived type is a class (or struct) which inherits from another class (or struct). A derivative cannot inherit from a primitive, enum or union. Derived types are also, by definition, user-defined types.


User defined data type in c plus plus?

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


Define objects and show how they act as user defined data type in c plus plus with the help of a programme?

An object is an instance of a class. A class is a data type that combines data and the specific methods that operate upon that data into a self-contained entity. To prove that objects are user-defined types, consider the following: class foo { }; int main() { foo a; foo b; foo c = a + b; // ERROR! } The reason there is an error is because the plus operator (+) only works with primitive data types (integral, arithmetic and built-in data types). foo is neither an integral, arithmetic nor built-in data type, thus the plus operator is not supported. However, if you provide a user-defined plus operator overload (foo::operator+) that accepts a constant reference to a foo object, the code will compile. It's up to you, the class designer, to provide the appropriate implementation.


Can a C plus plus user defined function return a value?

Absolutely. Indeed, any function (user-defined or built-in) that does not return a value is not really a function, it is simply a procedure.


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.


What is data hidening in c plus plus?

Data hiding is a property that only relevant information is exposed to the user and rest of the informations remains hidden from the user


How do the IO facilities in C plus plus differ from those in C?

The C standard library IO facilities are not extensible. For instance, the printf() and scanf() functions cannot handle user-defined types. However, the C++ standard library provides IO streams with insertion and extraction operators (<< and >>) that can be overloaded to support any user-defined type.


What is data type in c plus plus?

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.


What are the different datatypes in c plus plus?

There are far too many to provide a comprehensive list -- and new datatypes are being created all the time. However, datatypes can be split into two broad categories: built-in types and user-defined types. The built-in types include all the primitive datatypes inherited from C (including int, long, short, char, float, etc), which can be signed or unsigned and are often called intrinsic types. Built-in types also include the containers found in the standard template library (STL), including string, vector and list, along with their associated iterators. To make use of the STL types, you must include the appropriate library headers. User-defined types are those you define yourself, typically class, struct or union definitions, as well as enums and typedefs. User-defined types also include those types provided by a third-party, excluding the built-in types. Since user-defined types are not strictly part of the language, and new types are created every day, it would be impossible to list them all.


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.


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

Constant data and constant functions.


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.