TECHGRAVE

Monday, April 17, 2006

How the Object/Classes are compiled?

How the Object/Classes are compiled?

To be specific, how are classes represented in binary code?
This is a very interesting question. In c++ an object or a structure is simply a block of memory that is equal to the sum of sizes of itsmembers in the simple case.
So
class CTest
{
public: int a;
void set(int v){a=v}
}


Could be boken down to an amlost equivalent c representation :
Struct CTest
{
int a;
}

void set(int v, Ctest * this)
{ this->a = v }

Don't take it at face value as such but this is almost what it means.

Why i++ ++ won't work in C?

Why i++ ++ won't work in C? [Also ++i++ etc. will not work]

i++ yeilds a value, and operators don't work on values, they work on objects.
So the second ++ fails, with the error 'lvalue required' ie,address required.
Same is the case with ++i++.
To enumerate i++ is equivalent of(i = i + 1)
Correct ?
So an i++ ++ would be (i = i + 1) = ???That is the expression returns a value and not a variable and so thesecond operand can work on a value type for the simple reason thatsaying 5++ or 10++ is invalid.

64 bit OS and 32 bit OS. diff?

What is the difference between 64 bit OS and 32 bit OS.
64 bit OS may use inverted page tables, What else?

A 64-bit OS needs to have full support for 64-bit hardware plus support for 32-bit legacy programs.

A 64 bit OS is one that takes advantage of an underlying 64 bit hardware architecture. That means that typically the registers would be 64bitswide and integer operations would occur on 64 bit values. Also typically hardware architectures don't have such simple changes as simply lengething the registers - so a typical OS would utilise the newfeatures of the hardware.

I don't know what inverted page tables are, can you tell me ?You can read a little about the new IA64 acrhuecture here: (veryinteresting)http://msdn.microsoft.com/msdnmag/issues/01/06/hood/
http://msdn.microsoft.com/msdnmag/issues/01/07/hood/Win 2003 server has a 64 bit version along with a host of other coolthings.

Compiled program fasteer why?

it is obvious that it is convinient to develop a NEW program using an interpreter(C) rather than a compiler.But once an error free pgm has been developed, a compiled version will normally EXECUTE FASTER than an interpreter..WHY?


a compiler program is one that is convertedt into a sequence ofbytes that denotes the opcodes that the processor of your computer willunderstand. So when a compiled program runs all it actually does is thatthe bytes of program are sent to the procress one by one and this causesthe processer to do the things that you wanted the program to do.

When you interpret a program the 'interpreter' program is the one thatis executed by your processor and it executes sequences ofcommands/intructions that in effect will simulate the commands in yourprogram. So since at every point there is mediator between your programand the computer hardware, the interpreted program runs slower.Do you understand ?