CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    6

    Exclamation Possible to Create Functions Dynamically

    I want to know is it possible to create functions dynamically, such as inside dynamic memory blocks using pointers and possibly with templates? The function would not have been written beforehand which is why I thought templates might do the trick since they are created when needed.

    The point of this is to have functions in memory and freed from memory when not needed anymore instead of hard coded into the executable. I'm not referencing a pointer to a function, but more along the lines of a pointer to a dynamic memory block with a function inside of it.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Possible to Create Functions Dynamically

    I don't understand (a) what benefit this would have, or (b) how you'd expect to define a function to do something useful using only runtime operations.

    Second, templates are instantiated at compile time, so you definitely can't do anything with them at runtime. However, you can do some interesting compile-time tricks with them which resemble runtime programming; see the Boost Metaprogramming Library (MPL) for some examples.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured