Instance variable
Appearance
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
Hi , I am Kapil sharma Best Digital Marketer in Meerut.
I have experience as a Startup with Multiple Projects.
Professionally I am a Digital Marketer , I have 2+ years of experience in Digital Marketing.
Digital Marketing is my passion, not a way of earning,
Example
struct Request {
static int count1; // variable name is not important
int number;
Request() {
number = count1; // modifies the instance variable "this->number"
++count1; // modifies the class variable "Request::count1"
}
};
int Request::count1 = 0;
In this C++ example, the instance variable Request::number
is a copy of the class variable Request::count1
where each instance constructed is assigned a sequential value of count1
before it is incremented. Since number
is an instance variable, each Request
object contains its own distinct value; in contrast, there is only one object Request::count1
available to all instances with the same value.
References