File tree 3 files changed +22
-2
lines changed
3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ class Anish : public Person {
23
23
void intro () {// function overridden in derived class
24
24
25
25
cout<<" Hi I am Anish" <<endl;
26
- Person::intro (); // calling pure virtual function
26
+ // Person::intro(); //calling pure virtual function
27
27
}
28
28
29
29
};
@@ -39,6 +39,8 @@ int main() {
39
39
Anish a;
40
40
a.intro ();
41
41
getIntro (&a);
42
+ a.Person ::intro (); // accessing the base class intro() function, though it is a pure virtual function
43
+
42
44
43
45
return 0 ;
44
46
}
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ int a=10 ;
7
+ int *ptr=&a; // ptr refers a and stores its mem address
8
+
9
+ cout<<a<<endl; // value of a
10
+ cout<<&a<<endl; // mem address of a-Hexadecimal
11
+ cout<<*&a<<endl; // value of a =10
12
+ cout<<*ptr<<endl;// value of a =10
13
+ cout<<&ptr<<endl;// address of ptr variable
14
+ cout<<&*ptr<<endl;// address of a as value of *ptr=10 and address of 10 is add of a
15
+ cout<<*&ptr<<endl;// address of a, as &ptr is address of ptr and ptr stores the mem address of a as value
16
+ return 0 ;
17
+ }
Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ void getIntro(Person *p)
39
39
}
40
40
41
41
42
- int main () {
42
+ int main ()
43
+ {
43
44
44
45
Person *p1,*p2;
45
46
Anish a;
You can’t perform that action at this time.
0 commit comments