// ============================================================================ // // Copyright (c) 1997 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------------- // // release : $CGAL_Revision: $ // release_date : $CGAL_Date: $ // // file : test_modifier.cpp // chapter : $CGAL_Chapter: Protected access to the internal repr.$ // package : $CGAL_Package: Modifier 1.2 (07 Apr 1999) $ // source : modifier.fw // revision : $Id$ // revision_date : $Date$ // author(s) : Lutz Kettner // // coordinator : INRIA, Sophia Antipolis // // Protected access to the internal representation. // ============================================================================ #include #include #include using CGAL::Modifier_base; class A { int i; // protected internal representation public: void delegate( Modifier_base& modifier) { modifier(i); // check validity CGAL_postcondition( i > 0); } int get_i() const { return i;} // read access }; struct Modifier : public Modifier_base { void operator()( int& rep) { rep = 42;} }; int main() { A a; Modifier m; a.delegate(m); assert( a.get_i() == 42); return 0; } // EOF //