1. #1
    Slabby's Avatar
    Registered
    29/12/03
    Location
    Torhout
    Posts
    4,010
    iTrader
    2 (100%)
    Mentioned
    0 Post(s)
    Reputation
    0/148

    [C++] Typename FUNC

    Stel ik heb een functie

    template <typename FUNC>
    ... functie(const FUNC &func)

    Op welke manier moet je een functie meegeven als parameter met deze functie ? Bij gewoon invullen wordt die inner functie natuurlijk al uitgevoerd en staat er dus in wezen void als argument... Google laat me hierbij precies zwaar in de steek.
    no votes  

  2. #2
    Slabby's Avatar
    Registered
    29/12/03
    Location
    Torhout
    Posts
    4,010
    iTrader
    2 (100%)
    Mentioned
    0 Post(s)
    Reputation
    0/148
    Ik bedoel inderdaad dit

    Code:
    template<typename FUNC>
    void functie(const FUNC& t)
    {
    	t();
    }
    Alleen werkt dit stukje code enkel als je als argument een functie zonder parameters meegeeft. Kan dit uitgebreid worden voor functies met parameters ?
    no votes  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in