If it's a light bulb or heater, it's just a resistor.

First, forget that it's alternating current, just to simplify things.
Think of the power source as a really big 220 volt battery.

If it's drawing 1500 watts, divide that by 220, and that will tell you the current I in Amperes.
(That just measures how many electrons per second are flowing. An Ampere is about 6x10^23 electrons per second.)

To get the resistance R in Ohms, just divide the voltage V (220 volts) by the current I that you got above.
(An Ohm is just the number of volts it takes to push one Ampere through the resistor.)

I hope you can see that the smaller the resistance is, the bigger the current is, and when you multiply that by the voltage, you get the power.

So the way you make a bigger heater or light bulb is by giving it less electrical resistance.

If you want to go back to alternating current (AC) the power is a time-average, and it swings up and down at twice the AC frequency.
I'll let you figure out why, if you want.

How do electrical devices suck electricity?
I have several functions in my program that look like this:

void foo(int x, int y)


Now I want my program to take a string that looks like:

foo(3, 5)


And execute the corresponding function. What's the most straightforward way to implement this?

When I say straightforward, I mean reasonably extensible and elegant, but it shouldn't take too long to code up.

Edit:

While using a real scripting language would of course solve my problem, I'd still like to know if there is a quick way to implement this in pure C++.
