Is this an acceptable answer?
(I had to use reference when it wouldn't compile, sorry )
Yeah I suppose that's acceptable. Not really a function though, it's a macro. Since you were already on the recursive bandwagon you might as well just have done this:
int MultiplyBy321( int x )
if( x == 1 ) return 321;
else return MultiplyBy321(x-1) + 321;
But templates are always fun eh
Ok, i have a recursive add solution but someone might say it's a form of loop. Anyway, here it goes:
Yeah that works. loops would just include while/for/do/(i suppose some may say goto and label would also be a loop, but whatever...).
321 = 256 + 64 + 1 =>
x*321 = x*256 + x*64 + x
x*321 = x\<\<8 + x\<\<5 + x
thats the "lowlevel answer"
It's actually x \<\< 8 + x \<\< 6 + x. Maybe you just hit 5 instead of 6 but yeah, that's the answer I was expecting @Mihail121
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.
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...
Going to try now.
If people got more questions, bring em on this is fun.