Last active
August 22, 2020 04:01
-
-
Save domiyanyue/9e795abb1ea663bfe75569f370546fc0 to your computer and use it in GitHub Desktop.
RAII example
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
class WrapperA{ | |
public: | |
A *p; | |
WrapperA(){ | |
p = new A; | |
} | |
~WrapperA(){ | |
delete p; | |
} | |
}; | |
int demo1(){ | |
WrapperA a; | |
int r = a.p -> func(); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment