Posts

Showing posts from May, 2005

Importance of TypeSafety -An example

class Bank { private: bool bFirstLock; bool bSecondLock; BankVault* pBankVault; public: Bank() { bFirstLock=0; bSecondLock=0; pBankVault= new BankVault ; } bool IsLocked() { if(( true == bFirstLock) && (true== bSecondLock)) { printf("Both Locks unlocked- Bank is UNLOCKED\n"); return false; } else { printf("Bank is LOCKED\n"); return true; } }; }; //----------------------------------------------------- class Robber { short ForgedKey; void* pAceesor; public: Robber() { ForgedKey=0; }; RemoveLocks() { //This method has the instruction to set the first // 2 bytes (short) of the start of the class to value //257; This in binary is 00000001 00000001;ie the first 2 bytes to 1 ; //But since we are using the pointer of the Bank object to call //this method, it sets the first 2 bytes of the object of //bank to 00000001 00000001; But in the Bank object the first 2 //bytes are occupied by two boolean varia

Unix - Checking the virtual memory of process

ps -elf | grep In Solaris the size (SIZ) column specifies memory size