billroper: (Default)
[personal profile] billroper
The next person who casts away constness on an object that I'm deliberately returning as a const object because I don't want them modifying it except through the specific functions that I've provided to do so is going to get thrashed about the head and shoulders.

Date: 2004-07-27 09:49 pm (UTC)
From: [identity profile] mrlogic.livejournal.com
Hey, here's your problem:

#include Deviousness.h
#include MessedUpValues.h

void ScrewUpBillsCode()
{
     const BillsObjectType* billsObject = BillsFunction();
     BillsObjectType* screwedObject = const_cast<BillsObjectType*>(billsObject);
     screwedObject->member = k_CRAP;

// mwahaha
}

Date: 2004-07-28 11:44 am (UTC)
From: [identity profile] phillip2637.livejournal.com
How about...don't return objects you want protected? Return identifiers instead and and act as a proxy for the functions that you decide are valid.

Ya, I know, not nearly as satisfying as the "thrashing" thing. :-)

Profile

billroper: (Default)
billroper

January 2026

S M T W T F S
     1 2 3
4 5 6 78910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 8th, 2026 10:27 am
Powered by Dreamwidth Studios