Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My OO...

Name: Anonymous 2011-12-13 3:19

...it's violated!

http://programmers.stackexchange.com/questions/17031/when-c-handles-pop-in-your-c-code-and-break-your-pretty-oo-design

Anime avatar. Passive-aggressive rant. Autismal as fuck. That's gotta be someone from /prague/, amirite?

Name: Anonymous 2011-12-14 13:47

>>14
Here's how weak typing kills safety in your programs:

#include <iostream>
 
class Wallet {
        public:
                int money;
                Wallet() { money = 100; }
                void setMoney(int pounds) { money = pounds; }
};
 
class MyWallet : private Wallet {
        public:
                int getMoney() { return money; }
};
 
int main() {
        MyWallet *wallet = new MyWallet;
        reinterpret_cast<Wallet*>(wallet)->setMoney(9000);
        std::cout << wallet->getMoney(); // Output: 9000
        return 0;
}

Name: Anonymous 2011-12-14 14:19

>>17
You are implying that strong typing prevents this, but it doesn't. A malicious programmer (which is clearly what would be needed for your example) can directly modify application memory in any number of ways.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List