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

New GoF design pattern

Name: Anonymous 2014-04-29 4:31

CONSTIPATED ENCAPSULATION

#include <iostream>

class Anus
{
public:
Anus(int n=123):hax(&num) { num=n; }
void setNum(int n) { num=n; }
const int *const hax;
private:
int num;
} anus;

int main()
{
std::cout << *anus.hax << "\n";

anus.setNum(42);
std::cout << *anus.hax << "\n";

return 0;
}

Name: Anonymous 2014-04-29 15:08

>>5
But what if later on we want to make the object store in an obfuscated form? We could make the change transparent to the user by using accessors and mutators as an interface.

I do prefer the C# way, which intercepts assignments and evaluations so that you don't need to use the dumb getters/setters methods.

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