C 和派生数据类型?

发布于 2024-11-07 19:42:27 字数 96 浏览 2 评论 0原文

我知道 C 中的基本数据类型 - char、int、float 等。但是 C 语言中的派生数据类型到底是什么?

I know the fundamental data types in C - char, int, float etc. But What exactly are derived data types in C language?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

浅唱ヾ落雨殇 2024-11-14 19:42:27

标准的 6.2.5.20(嗯,草案;万岁free :) 涵盖派生类型

20 可以从对象、函数和对象构造任意数量的派生类型
不完整类型,如下:
-- 数组类型描述了一组连续分配的非空对象
特定的成员对象类型,称为元素类型。数组类型有
由它们的元素类型和数组中元素的数量来表征。一个
据说数组类型是从其元素类型派生的,如果其元素类型为 T,则
数组类型有时称为T 数组。数组类型的构造
元素类型称为数组类型派生
-- 结构类型描述了顺序分配的非空成员对象集
(并且,在某些情况下,是一个不完整的数组),每个数组都有一个可选的
指定的名称和可能不同的类型。
-- 联合类型描述了一组重叠的非空成员对象,每个成员对象
它具有可选指定的名称和可能不同的类型。
-- 函数类型描述具有指定返回类型的函数。函数类型是
其特征在于其返回类型及其参数的数量和类型。一个
据说函数类型是从其返回类型派生的,如果其返回类型是 T ,则
函数类型有时称为返回T的函数。建设一个
从返回类型推导出函数类型称为函数类型派生
-- 指针类型可以派生自函数类型、对象类型或不完整类型
类型,称为引用类型。指针类型描述了一个对象,其值
提供对所引用类型的实体的引用。派生自的指针类型
引用的类型T有时被称为T的指针。建设一个
来自引用类型的指针类型称为指针类型派生

这些构造派生类型的方法可以递归应用。

6.2.5.20 of the standard (well, a draft; hooray free :) covers derived types:

20 Any number of derived types can be constructed from the object, function, and
incomplete types, as follows:
-- An array type describes a contiguously allocated nonempty set of objects with a
particular member object type, called the element type. Array types are
characterized by their element type and by the number of elements in the array. An
array type is said to be derived from its element type, and if its element type is T, the
array type is sometimes called array of T. The construction of an array type from
an element type is called array type derivation.
-- A structure type describes a sequentially allocated nonempty set of member objects
(and, in certain circumstances, an incomplete array), each of which has an optionally
specified name and possibly distinct type.
-- A union type describes an overlapping nonempty set of member objects, each of
which has an optionally specified name and possibly distinct type.
-- A function type describes a function with specified return type. A function type is
characterized by its return type and the number and types of its parameters. A
function type is said to be derived from its return type, and if its return type is T , the
function type is sometimes called function returning T. The construction of a
function type from a return type is called function type derivation.
-- A pointer type may be derived from a function type, an object type, or an incomplete
type, called the referenced type. A pointer type describes an object whose value
provides a reference to an entity of the referenced type. A pointer type derived from
the referenced type T is sometimes called pointer to T. The construction of a
pointer type from a referenced type is called pointer type derivation.

These methods of constructing derived types can be applied recursively.

怎言笑 2024-11-14 19:42:27

从基本数据类型派生的数据类型称为派生数据类型。派生数据类型不会创建新的数据类型,而是为基本数据类型添加一些功能。

在 C 中,两种派生数据类型是:Array 和 Array。指针。

数组:数组是相同类型的变量的集合。它们存储在传染性内存分配中。

例如

int a[10];
char chi [20]; 

指针:

指针是一种特殊变量,它保存另一个变量的内存地址(内存中的位置)。

int i=10;
int *j;
j=&i;

这里,j 是一个整数指针,因为它保存整数变量 i 的地址。

Data types that are derived from fundamental data types are called derived data types. Derived data types don't create a new data type but,instead they add some functionality to the basic data types.

In C, two derived data type are : Array & Pointer.

Array : An array is a collection of variables of same type. They are stored in contagious memory allocation.

e.g

int a[10];
char chi [20]; 

Pointer :

A pointer is a special variable that holds a memory address (location in memory) of another variable.

int i=10;
int *j;
j=&i;

Here, j is a integer pointer as it holds an address of an integer variable i.

小梨窩很甜 2024-11-14 19:42:27

派生数据类型只不过是从基本数据类型构造出来的。
例如指针、结构、联合等。
整数我; int*ptr; ptr = &i;
“i”是整数类型的变量,它是基本数据类型。
这就是为什么指针必须基于数据类型。

Derived data type is nothing but it constructed from fundamental data type .
example is pointer,structure,union etc.
int i; int*ptr; ptr = &i;
'i' is variable of type an integer it is base data type.
that's why pointer must be based data type.

冷默言语 2024-11-14 19:42:27

派生数据类型是一种复杂的分类,它标识一种或多种数据类型,并由称为原始数据类型的简单数据类型组成。派生数据类型具有高级属性,其用途远远超出了作为其基本构建块运行的基本原始数据类型。

A derived data type is a complex classification that identifies one or various data types and is made up of simpler data types called primitive data types. Derived data types have advanced properties and uses far beyond those of the basic primitive data types that operate as their essential building blocks.

北陌 2024-11-14 19:42:27

派生数据类型源自基本数据类型(即:int、float、char、double、void)。他们不创建新的数据类型,而是使用基本数据类型来添加额外的功能。例如:数组:数组是相同类型的变量的集合。因此数组是派生数据类型。

Derived data types are derived from fundamental data types(ie: int, float, char, double,void). They don't create a new data type but use fundamental data type to add extra feature. Ex: Array: An Array is collection of variables of same type. Hence array is an derived data type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文