-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjPointer.cpp
More file actions
39 lines (35 loc) · 849 Bytes
/
Copy pathobjPointer.cpp
File metadata and controls
39 lines (35 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Object pointer : a pointer contains address of object
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
class Box
{
private:
int length,width,height;
public:
void setDimenstion(int x,int y,int z)
{
length = x;
width = y;
height = z;
}
void ShowDimension()
{
cout<<" length ="<<length<<" width ="<<width<<" height="<<height<<endl;
}
};
int main(int argc, char const *argv[])
{
system("cls");
Box box; //creating an object
Box *boxp; //creating a object pointer
boxp = &box; //assigning address of object
// box.setDimenstion(8,10,14);
// box.ShowDimension();
//calling method using object pointer using -> operator
boxp->setDimenstion(10,20,8);
boxp->ShowDimension();
system("pause");
return 0;
}