박성국
박성국

Reputation: 43

Is there a data object that is not a variable or a constant?

I am a student studying programming. I'm studying programming linguistics, and I'm asking for help because there's a part that doesn't work out well while solving the problem.

The problems are as follows:

For an elemental data type in a language with which you are familiar, do the following:

A. ...

B. Show a situation during execution where a data object of that type exists that is neither a variable nor a constant.

C. ...

The part I don't understand here is question number B. According to the textbook, data objects are variables or constants, and constants can be classified as literal and named constants, but data objects that are neither variables nor constants can be found. I'd appreciate your help.

I was solving the problem by setting the language that I am familiar with as C language.

Upvotes: 0

Views: 149

Answers (1)

pmg
pmg

Reputation: 108986

Not sure I understood your question...

Here are two unnamed objects

struct Foo { int bar; double quux; }
(struct Foo){42, 3.14159}

(int)42

you can use them through a pointer

struct Foo *foo = &((struct Foo){42, 3.14159});
foo->quux = 2.71828;

int *fooi = &((int){42});
*fooi = -1;

you can use them as function parameters

foofx((struct Foo){42, 3.14159});
foon((int){42});

https://ideone.com/ibhdYq <== with (struct Foo)
https://ideone.com/XB1bkO <== with (int)

Upvotes: 1

Related Questions