Listing 1: Simple definition of class Shirt
enum color { white, blue, tan, yellow };
enum form { regular, tall, big, formfit };
enum style { longsleeve, shortsleeve };
class Shirt { // Improved Brute-Force Method
color color_;
form form_;
style style_;
public:
Shirt() : color_( white ), form_( regular ),
style_( longsleeve ) {;}
Shirt& arg( color x ) { color_ = x; return *this; }
Shirt& arg( form x ) { form_ = x; return *this; }
Shirt& arg( style x ) { style_ = x; return *this; }
};
void fun( Shirt& );
int main() {
// You can define object with declaration-initialization
Shirt s6 = Shirt().arg( yellow ).arg( shortsleeve );
// You can also construct temporary objects on the fly
fun( Shirt().arg( tall ) );
fun( Shirt().arg( blue ).arg( shortsleeve ).arg( big ) );
return 0;
}