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

February 2026

S M T W T F S
1 2 34567
891011121314
15161718192021
22232425262728

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 4th, 2026 01:24 pm
Powered by Dreamwidth Studios