有一种方法可以在.main-div {
.input { ... }
.select { ... }
.a { ... }
.li { ... }
....
}
?
class Foo
{
int value;
public:
Foo() { value = -1; }
Foo(int value) {
if (value < 0) cout << "error\n"; else { cout << "ok\n"; this->value = value; }
}
operator int() { if (value < 0) cout << "error\n"; else return value; }
};
class Bar
{
Foo * fooArray;
public:
Bar() { fooArray = new Foo[4]; }
Foo & operator [](int i) { return fooArray[i]; }
};
int main()
{
Bar test;
int foobar = test[0];
test[1] = 4;
test[2] = -4;
cin.get();
return 0;
}