From: Wolfgang Bangerth Date: Thu, 3 Sep 1998 12:32:12 +0000 (+0000) Subject: Comment example. X-Git-Tag: v8.0.0~22707 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2fe09bd262bd13cfc5bb4fa0b12402b1e89818;p=dealii.git Comment example. git-svn-id: https://svn.dealii.org/trunk@550 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/reference.cc b/tests/base/reference.cc index 03c69251ca..ae7f092151 100644 --- a/tests/base/reference.cc +++ b/tests/base/reference.cc @@ -1,8 +1,9 @@ #include -#include #include + + class Test : public Subscriptor { public: @@ -16,19 +17,23 @@ public: } }; + + main() { Test a; const Test b; - SmartPointer r=&a; - const SmartPointer s=&a; - SmartPointer t=&b; - const SmartPointer u=&b; - - a.f(); - b.f(); - r->f(); - s->f(); - t->f(); - u->f(); + SmartPointer r=&a; + SmartPointer s=&a; + SmartPointer t=&b; // this one should give a warning + SmartPointer u=&b; + + a.f(); // should print "mutable", since #a# is not const + b.f(); // should print "const", since #b# is const + r->f(); // should print "mutable", since it points to the non-const #a# + s->f(); // should print "const", since it points to the non-const #a# + // but we made it const + t->f(); // should print "mutable", since #b# is const, but + // we casted the constness away + u->f(); // should print "const" since #b# is const }