Reputation: 1403
Why is an array called a derived data type?
Upvotes: 1
Views: 4233
Reputation: 251
http://in.answers.yahoo.com/question/index?qid=20071229234805AAyuACh
Upvotes: 0
Reputation: 1270
C provides us with mainly five generic/primary data types, Here are the types & their ranges.
In case, if any of the above are not sufficient for representing any type for your problem, C has provided us with compound types like struct where you can defined your own types.
For eg: Fractions. To represent Fraction we need two integers, one for the numerator & second for the denominator.
So, we define a strcuture like below
typedef struct {
int numer;
int denom;
} fraction;
And from now, we can start using fraction to declare any new variable. fraction, here is a user-defined data type also referred some times as derived data type.
I am not aware that arrays are also referred as data types. To my knowledge, Array is a collection of finite number of elements of same data type, where each element is accessed by an index ranging from 0 to n-1, where n is no. of elements in the array.
With this defintion, I am not sure whether Arrays can be classified as derived data types. Like you, I am also waiting for a reason if at all they are classifed as derived data types.
Upvotes: 1
Reputation: 22634
The reason is that they are derived from the fundamental data types. (Actually, the version of the standard I looked up puts them under Compound types.)
Upvotes: 7
Reputation: 554
None of the base datatypes provide u to store more than 1 value [ Eg : int, char, float etc ] An array is nothing but, an extended form of the base data type, holding N items of the base data type. So, due to this, array is called the derived data type.
Upvotes: 0
Reputation:
The term does not appear in the C++ Standard, as far as i can determine. Where did you read it?
Upvotes: 3