Created
July 17, 2020 22:11
-
-
Save talreg/080a4de3c0355494c7aa51bd4aabbea7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
struct Test2 | |
{ | |
int value; | |
int get_value()const { | |
return value; | |
} | |
void inc_val(){ | |
value++; | |
} | |
Test2(){ | |
value=get_value(); | |
} | |
}; | |
int main(){ | |
cout <<test2.get_value()<<endl; | |
const Test2* ptest2=new Test2(&test1); | |
ptest2->get_value(); | |
ptest2->inc_val(); | |
Test2* const ptest22=new Test2(&test1); | |
ptest22->inc_val(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment