Re: nested functions in VC++
- From: Murrgon <murrgon@xxxxxxxxxxx>
- Date: Fri, 22 Apr 2005 09:58:39 -0400
alexl wrote:
I think what I am looking for is a "nested function" which C++ doesn't officially support.
Actually, you can put a function within a function, but not in the normal sense. Try something like this:
void MyClass::SomeFunction()
{
struct Inner
{
static int InnerWorkings(int i)
{
return i * 4;
}
}; printf("Inner function call result: %d\n", Inner::InnerWorkings(5));
}You would have to wonder why one would do this because for the most part you shouldn't need to. However on a few rare occasions it does come in handy.
Murrgon .
- References:
- nested functions in VC++
- From: alexl
- nested functions in VC++
- Prev by Date: function definition in .cpp file causes LNK2001
- Next by Date: Re: C++ in ternms of C
- Previous by thread: Re: nested functions in VC++
- Next by thread: How can I get the size of this?
- Index(es):