tags:

views:

257

answers:

10
int* p;
int& r;
int i;
double* p2;
double& r2;
double d;

p and p2 are pointers, r and r2 are references, but what are i and d? (No, I am not looking for the answer "an int and a double")

I am looking for a name to use for "normal" variables, setting them apart from pointers and references. I don't believe that such a name doesn't exist (after all, I can't be the first one who wants to distinguish them from pointers and references. I do have the feeling that it's something really easy and I'm just missing it here.

Who knows what to call "normal" variables?

Additional info

I am looking for a name that can refer to anything but references and pointers, so including classes. The whole same story could be held when the following was included as well:

MyClass* p3;
MyClass& r3;
MyClass c;

I am not looking for a way to refer to i, a way to refer to d and a way to c. I am looking for a way to refer to the group (of non-references, non-pointers) which i, d and c are part of.

+1  A: 

They are just variables. Not pointers and not references, variables.

Yuval A
So you would talk about member references instead of reference member variables?
Jasper
In the specific case of members, the standard calls them *member* in general (that includes function members) and *data member* to discriminate from typedefs, subclasses, function members... In general you will see that people call them *member variables* or *attributes*, sometimes plain *variables*. Note that this applies to all data, regardless of whether it is an instance, a pointer or a reference. When talking, make the language as clear as possible. *A member of pointer to T type* is much clearer than a *pointer member* (note that *pointer **to** member* is a whole different thing)
David Rodríguez - dribeas
A: 

Values, or variables.

DanDan
A pointer (which is simply another type) has a value as well. In general, values are the concrete instances of types.
pmr
I was just thinking pass by value, as opposed to pass by reference or pointer.
DanDan
+7  A: 

Pointers and references are variables as well. I think it is sufficient to say that i is a variable of type int and p is a variable of type pointer to int. If they are members of a class i is a member variable of type int would be the most precise description.

Edit: There is no definite answer to your question. int would be a fundamental type in standard terminology. Other types as classes, unions and pointers are called compound types. This just isn't helpful in your case as you would refer to

A* a;
int* b;
A c;

as only consisting of compound types. But you want to emphasize that you use pointers. Just say it.

pmr
This is the right answer.
DeadMG
But hey, I didn't ask for what's sufficient to say, or what's the most precise description. I asked for a name for the group of non-reference non-pointer variables. A name which allows me to say, I am using pointers all over the place, but there in many cases there is no reason to do so, so I should change them to <normal variable>s wherever possible.
Jasper
@Jasper: In C++, the name is "fundamental types".
Mike Seymour
@Jasper: You could say: "I am using pointers all over the place, but there are many cases where there is no reason to do so, so I should remove the levels of indirection in these places."
Daniel Trebbien
+7  A: 

If I understand what you are talking about, I would call it a value type.

tvanfosson
I just grabbed my copy of "Elements of Programming" and thought about it: a sequence of bits together with a pointer type would constitute a value type as well. Do you refer to another definition of value type?
pmr
@pmr - Whlie you could certainly treat a pointer as a value, eventually we really care about the value that the pointer references. I don't have a copy of the book in front of me, but I would expect that in context the interpretation of the bits as something other than a reference to something is implied.
tvanfosson
@tv I realized that the term `value type` is used in C# to mean exactly what the OP is looking for. Unfortunately there is no such term in C++.
pmr
+3  A: 

If you want the official terminology, then the C++ standard defines:

  • fundamental types, built-in value types such as int and double, and
  • compound types, including pointers and references, and also arrays, functions, classes, unions and enumerations.

It also uses the terms "object types", "reference types" and "function types", but it seems a bit vague to me about whether a pointer is an "object type" or a "reference type".

If you want to include fundamental types and classes, I would use the term "object type", and leave it to pedants to quibble about whether that should include pointers.

Mike Seymour
That's a step in the right direction, but I was looking for a name for the group in which classes are also included. I'm sorry if that wasn't clear from my question.
Jasper
A: 

i and d are consistently called objects in the C++ standard. But, then again, so are p, p2, and objects of class type such as the "c" of MyClass c;.

Personally I like calling i, d, and p objects, though it might be a little bit confusing to programmers of other languages such as Java, where they would be known as primitive variables with the term objects reserved for instances of classes.

EDIT: Instead of

I am using pointers all over the place, but there are many cases where there is no reason to do so, so I should change them to <normal variable>s wherever possible.

I would say: "I am using pointers all over the place, but there are many cases where there is no reason to do so, so I should remove the levels of indirection wherever possible."

Daniel Trebbien
I gave an example as I thought there to be an answer usable in many more cases than just the one I am facing and I didn't want to complicate the matter. However, the real case I am facing is a bit more complicated: I have removed the usage of pointers in a large project and I want to give a description of where, when and how I turned them into references/"objects"
Jasper
+2  A: 

Value types (value variables) was my first thought, but it seems to make some people uncomfortable, so nonreferential types (nonreferential variables) works just as well: pointers and references are both "referential types" in the sense that they refer to another location, while ordinary value types do not.

Jon Purdy
+1  A: 

I think you want to use "non-pointer and non-reference type". There is no name especially designed for your purpose, i think.

A name which allows me to say, I am using pointers all over the place, but there in many cases there is no reason to do so, so I should change them to s wherever possible.

It sounds to me you look rather for "pass by copy" or "copy" vs "pass by reference" or "reference". The fact that you can pass a pointer by value makes it impossible to use an absolute term, but makes it necessary to use a term tied to the usecase:

int **p;

Is this a variable used to change a pointer of type int* (then it would be "pass by reference" in the sense you aim to modify the referent. To clarify that a pointer is used, you may wish to use the term "pass by pointer" too), or is this variable just used to hold a value of type int** (then it would be "pass by value" in the sense that you copy such a value)?

Johannes Schaub - litb
I'm not looking for "pass by" terminology, I am looking for (member) variable terminology.
Jasper
@Jasper then use "copy" or "reference", i think. As in "i hold that variable by reference in my class"
Johannes Schaub - litb
A: 

I typically call those "plain ol' data" (POD) variables, after the convention of referring to a struct as "POD" if it contains only data members (no functions). That's not an official convention, but it gets the point across (for simple types like int and float, it doesn't apply for classes).

I have also heard these types of variables called "concrete" variables. I think the distinction that was trying to be made is that these variables are something in and of themselves, whereas pointers and references simply tell you about some other piece of data somewhere else.

More than anything else, I hear these "loose" variables (that is, not a member of another object) referred to simply by their type (integer, floating-point number, class, etc).

bta
POD is something else, it's a narrower concept, as there are things you can do with PODs that you cannot with complex classes (actually, POD is defined in the standard - the next standard is actually going to change that definition slightly)
Jasper
A: 

I think we should call them OBJECTs. I think it's no need to be that strict.

Consider:

typedef int *, pint;
pint foo;

What do you think foo is?

Euyuil