edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] scope test
@ 2014-02-12 15:05 Karl Dahlke
  0 siblings, 0 replies; only message in thread
From: Karl Dahlke @ 2014-02-12 15:05 UTC (permalink / raw)
  To: Edbrowse-dev

Still exploring C++, I wanted to make sure the Compartment macro
didn't fire its constructor if you didn't reach it in execution,
even though it is at the highest scope of the function,
and I was pretty sure it wouldn't, but here is a little program to prove.
Think of foo as our AutoCompartment.
It constructs, unless you type in a q.

#include <iostream>
using namespace std;

class foo {
public:
foo(void) { cout << "hello\n"; }
~foo(void) { cout << "goodbye\n"; }
};

int main()
{
string s;
getline(cin, s);
if(s[0] == 'q') return 0;
foo f;
}

Karl Dahlke

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-12 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 15:05 [Edbrowse-dev] scope test Karl Dahlke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).