asked 113k views
3 votes
Programmers say the data items are ____ only within the module in which they are declared.

asked
User Rickul
by
8.4k points

1 Answer

7 votes
Data items are "local".

Consider the following example in C++.


class MyClass
{
public:
void setX(int x)
{
this->x = x;
}

private:
int x;
};


We have an integer variable local to the scope of the class declaration, and we have another integer variable local to our setX() function, though we have no global functions, that's something you want to try to avoid as a general rule of thumb.
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.