Quote:
Originally posted by Taurus:
void main()
{
A a;
while(a)
{
printf("%d\n",(int)a);
}
}
Write class A to make the output of above program as follows.
1
2
3
4
5
6
|
ах ты поизвращаться вздумал? ну тогда получай:
Code:
class A
{
public:
operator int() { for(int i = 0; i < 6; cout << ++i << endl); exit(0); return 0; }
};
или:
Code:
class A
{
public:
operator int() { return 0; }
A() { for(int i = 0; i < 6; cout << ++i << endl); } // или перенсети это в деструктор!
};
try this! :
Code:
class A
{
#define A for(int i = 0; i < 6; cout << ++i << endl)
#define a 0
};
правда, директивы препроцессора не назовешь оределением класса