// Bank account objects in C #include #include typedef struct accstruct * account; struct accstruct { int balance; }; // constructor account newaccount(int bal) { account A = (account)malloc(sizeof(struct accstruct)); A->balance = bal; // set init balance return A; } int inquiry(account A) { return A->balance; } void deposit(account A, int amt) { A->balance += amt; } void withdraw(account A, int amt) { if (amt<=A->balance) A->balance -= amt; } int moremoney(account A, account B) { return (A->balance > B->balance); } ///////// int main(int argc, char** argv) { account myaccount = newaccount(100); account youraccount = newaccount(200); withdraw(myaccount,50); // not myaccount->withdraw(50); deposit(youraccount,100); if (moremoney(youraccount,myaccount)) printf("you have more money than I do\n"); return 0; } /* How is this "inferior" to Java? Only real difference so far: everything is public (is your balance really secure?) Garbage collection,type safety are other comparisons to Java, but these issues are arguably orthogonal to oop. We're interested in OOP HERE! */