What is a base type?

closed account (EwCjE3v7)
What is a base type?
I presume it's the type before the variable name
Ex. Int x = 10;
The int is the base type
If I'm wrong please correct me.
Thank you
Last edited on
Out of context I have no idea what it means. In what context did you read this term?
closed account (EwCjE3v7)
It is in my book, c++ primer fifth edition.

As we’ve seen, a variable definition consists of a base type and a list of declarators. Each declarator can relate its variable to the base type differently from the other declarators in the same definition. Thus, a single definition might define variables of different types
There are so-called fundamental types in C/C++. For example int is a fundamental type while structures, unions and arrays are compound types.
Last edited on
My guess he means something like int i, *ptr, &ref; where int is base and i, *ptr, and &ref are declarators.
naraku9333 wrote:
My guess he means something like int i, *ptr, &ref; where int is base and i, *ptr, and &ref are declarators.


More specifically i, ptr and ref are the names, * and & are type modifiers - all forming a declarator.
Last edited on
closed account (EwCjE3v7)
So a base type is the int in here
int x = 0, *px;
right?
There is no such notion as the base type in C++. There are such notions as type specifiers and declarators. In your example int is a simple type specifier. x and *px are declarators.
Last edited on
closed account (EwCjE3v7)
Oh ok.than why the hell would my book use it? That's stupid
May I ask, the name and author of your book?
I found only one mention about base type in the C++ Standard. These words are used to denote base class.
@CaptainBlastXD

Oh ok.than why the hell would my book use it? That's stupid


In fact words "base type" can be synonyms of the C++ term "fundamental type".
The name of the book is given above as c++ primer fifth edition.

So the authors are apparently Stanley B. Lippman, Josée Lajoie, and Barbara E. Moo

I think the authors are using the word base in a looser sense than it has in base class. e.g. base type = the type on which things are based, rather than the type that is inherited from (or whatever.)

It is prob a bit of an unfortunate choice, given the resonance between "base class" and "base type". But what word could be used here instead, to make it clear that the types of the variables can differ from the "original" type? You can't switch to simple (or fundamental, basic, ...) as you can base your declarations on compound types as well.

Andy
Topic archived. No new replies allowed.