diff options
Diffstat (limited to 'libtests/pointer_holder.cc')
-rw-r--r-- | libtests/pointer_holder.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libtests/pointer_holder.cc b/libtests/pointer_holder.cc index 173a8266..c255df5a 100644 --- a/libtests/pointer_holder.cc +++ b/libtests/pointer_holder.cc @@ -12,6 +12,7 @@ class Object Object(); ~Object(); void hello(); + void hello() const; private: static int next_id; @@ -38,8 +39,21 @@ Object::hello() std::cout << "calling Object::hello for " << this->id << std::endl; } +void +Object::hello() const +{ + std::cout << "calling Object::hello const for " << this->id << std::endl; +} + typedef PointerHolder<Object> ObjectHolder; +void callHello(ObjectHolder const& oh) +{ + oh.getPointer()->hello(); + oh->hello(); + (*oh).hello(); +} + int main(int argc, char* argv[]) { std::list<ObjectHolder> ol1; @@ -74,6 +88,9 @@ int main(int argc, char* argv[]) } ol1.front().getPointer()->hello(); + ol1.front()->hello(); + (*ol1.front()).hello(); + callHello(ol1.front()); ol1.pop_front(); std::cout << "goodbye" << std::endl; return 0; |