Created
June 18, 2010 22:12
-
-
Save benjamn/444300 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 std::cout; | |
using std::endl; | |
int main() { | |
// Make the struct immutable so that public access is safe. | |
const struct AutoFoo { | |
~AutoFoo() { | |
// On destruction, do something with the members. | |
cout << x << ", " << y << endl; | |
} | |
int x, y; | |
} af = { | |
// Initialize the members without explicit constructor. | |
1, 2 | |
}; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment