pgrm_014.cpp
Problem Statement
pgrm_014.cpp
this pointer
Source Code
cpp
#include<iostream>
using namespace std;
class myclass {
private:
int value1;
int value2;
public:
void setValue(int v, int value2) {
this -> value1 = v;
this -> value2 = value2;
}
void printValue() {
cout << "Value1: " << this -> value1 << endl;
cout << "Value2: " << this -> value2;
}
};
int main() {
myclass obj;
obj.setValue(23, 123);
obj.printValue();
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
● Author - Amit Dutta