Thread: automatically disassociating pointers

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is moo supposed to be the function to call then? You can use functors and function pointers.
    Code:
    template<typename Class_t, typename Fnc_t> void foo(Class_t& obj, Fnc_t FncPtr)
    {
        (obj.*FncPtr)();
    }
    
    // Or alternatively
    template<typename Fnc_t> void foo(Fnc_t FncPtr)
    {
        FncPtr();
    }
    Last edited by Elysia; 07-16-2009 at 06:25 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Code:
    (obj.FncPtr)();
    Code:
    (obj.*FncPtr)();
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Whoops, my fault. Post fixed.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I was wondering, what is the official/more likely name of this?
    Boost? Specifically boost::weak_ptr.
    Last edited by VirtualAce; 07-16-2009 at 04:58 PM.

  5. #20
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    This is pretty much a manifestation of the observer pattern, with automatic disconnection.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  2. Pointers to function(function pointers)
    By abhishek_charli in forum C Programming
    Replies: 4
    Last Post: 06-23-2002, 01:24 AM
  3. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  4. Pointers pointers pointers...
    By SMurf in forum C Programming
    Replies: 8
    Last Post: 10-23-2001, 04:55 PM