I've been wondering about something for a while now. You can make nameless variables by allocating memory to pointers, such as
Code:
int *ptr = new int;
from the tutorial. That I understand. What I wonder, however, is if it's possible to make an unnamed function by assigning a block of code to a function pointer. For example, would this work?:

Code:
#include <cstdarg>
 
// this function should be called with only two int variables, the va_list is to access them
int (*mult)(int, int, ...) = {
va_list arglist; va_start(arglist, 0); // will this allow access to the first variable? return va_arg(arglist, int) * va_arg(arglist, int); }
I know that wouldn't be very useful, and it wouldn't be good form, but is it at all possible to make a nameless function with something like this?

If so, I can think of a way to make a more secure (but cumbersome) login feature for some programs: Instead of having the sign-in box accept a password, have it accept a variable assignment as the "password". The sign-in box could be connected to an interpreter, which will read and execute this assignment. Now, if you don't actually include a function that allows the user to log in as part of the program, but instead have the user input a new function into a variable, you could prevent access to only those who know not only what steps your program needs to perform to log in, but also which function pointer to use.


(Oh, and if you're wondering about my account name, I like to use the same name on every forum, or as close to it as possible.)