What is a base type?

Aug 24, 2013 at 11:56pm
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 Aug 24, 2013 at 11:58pm
Aug 25, 2013 at 12:03am
Out of context I have no idea what it means. In what context did you read this term?
Aug 25, 2013 at 1:21am
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
Aug 25, 2013 at 1:28am
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 Aug 25, 2013 at 2:39am
Aug 25, 2013 at 5:33am
My guess he means something like int i, *ptr, &ref; where int is base and i, *ptr, and &ref are declarators.
Aug 25, 2013 at 6:20am
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 Aug 25, 2013 at 6:21am
Aug 25, 2013 at 11:32am
closed account (EwCjE3v7)
So a base type is the int in here
int x = 0, *px;
right?
Aug 25, 2013 at 12:03pm
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 Aug 25, 2013 at 12:04pm
Aug 25, 2013 at 8:11pm
closed account (EwCjE3v7)
Oh ok.than why the hell would my book use it? That's stupid
Aug 25, 2013 at 8:14pm
May I ask, the name and author of your book?
Aug 25, 2013 at 8:22pm
I found only one mention about base type in the C++ Standard. These words are used to denote base class.
Aug 25, 2013 at 8:24pm
@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".
Aug 25, 2013 at 8:35pm
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.