what you win is the satisfaction that you are one with the force...err...i mean with c++. And yeah by all means just post the answers the them right here. Ill edit my above post and tell people not to scroll down if they don't want to see any answers.

Q 014) Rewrite the following function so that the following conditions are satisfied:
A) the multiplication operator ('*') is not used.
B) the division operator ('/') is not used.
C) the function does not make use of loops.
D) And no using assembly either
int MultiplyBy321(int val)
{
int res;
res = val * 321;
return res;

Q 014) Rewrite the following function so that the following conditions are satisfied:
A) the multiplication operator ('*') is not used.
B) the division operator ('/') is not used.
C) the function does not make use of loops.
D) And no using assembly either
int MultiplyBy321(int val)
{
int res;
res = val * 321;
return res;
}

REMEMBER: DO NOT scroll past this point if you dont want to see the answers to some questions.

[snapback]13392[/snapback]

Ok, i have a recursive add solution but someone might say it's a form of loop. Anyway, here it goes:

It's the biggest negative value a short can hold. But 32767 is the biggest positive number so 32768 has no positive. The result can be found by negating all bits of 0x8000 and adding 1 (the equivalent of a negation). Which is again 0x8000 or -32768.

Isn't shift exactly kind of multiply operator? Oh damn, if you are going to give questions be more specific, ok?

If you are going to answer questions then read the question first. I said dont use the "multiplication operator". I didn't say dont multiply. But either way, shift is not *exactly* a multiply operator. It's more of a subset of the multiply operator - ie: only multiply by powers of two.@Nick

Here's an extra question: How to get a pointer to a constructor? Don't take the question too literal, solve the problem.

Nice one! You cant get a direct pointer to the class constructor. apparently msvc is not letting me do what I want again (compiler error C2277) . But Im guessing that placement new is going to come in handy for this one. a pointer to a function that calls placement new or something. Can you get a pointer to placement new??? That would *technically* be a pointer to the ctor...

But Id say that that piece of code is calling a bunch of virtual function in the class script_t. Code is an array of the indices of where the function addresses are stored in vftable. And Frame would simply be the standard parameter that all the functions accept.

It's not virtual functions, but a static array of opcodes supported by my virtual machine, and Code is simply the bytecode dereferenced to give the index to the opcode to execute. Frame is the script execution frame, which holds the call- and variablestack. The '*script_t::vftable[*Code++]' is just the opcode dereferenced, and the 'Script->' infront of it is the context in which it is executed.

jesus, this is the equivalent to the theme of carving chess pieces in the Shawshank Redemption. Don't you people have better things to do? Program some actual stuff...get a job....get a life. Heck, carve some chess pieces.

I started self learning C++ this summer, and it's really interesting reading all this I tried to get Herbert Schild (sp?)'s C++ ref, as I loved the C version, but my hopeless bookshop didn't stock it (I had gift vouchers for there). It's now on the Amazon Christmas cart . Is it a good / the best reference book for covering the whole basic language?