CPPTOTD
-
?: is the only operator you cannot override in C++ Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard -
C++ trick of the day. As my work day was coming near to close, I was browsing to the source code of Generative Programming book.. I saw some code like this :-
Matrix m = 1, 2, 3 ,4 ,5;
That time I relaized that , operator can also be overloaded. I wrote something like this :-
class dummy
{
public:
std::vector vec;dummy& operator,(const int& val) { vec.push\_back(val); return \*this; } dummy& operator = (const int& val) { vec.push\_back(val); return \*this; }
};
int main(int argc, char* argv[])
{
dummy dum;dum = 1, 2, 3, 4, 5; for(int i = 0; i < dum.vec.size(); i++) { cout << dum.vec\[i\]; } return 0;
}
This is one of the neatest tricks I have seen with C++. Simply amazing. C# is fundamentally broken. - Christian Graus
-
C++ trick of the day. As my work day was coming near to close, I was browsing to the source code of Generative Programming book.. I saw some code like this :-
Matrix m = 1, 2, 3 ,4 ,5;
That time I relaized that , operator can also be overloaded. I wrote something like this :-
class dummy
{
public:
std::vector vec;dummy& operator,(const int& val) { vec.push\_back(val); return \*this; } dummy& operator = (const int& val) { vec.push\_back(val); return \*this; }
};
int main(int argc, char* argv[])
{
dummy dum;dum = 1, 2, 3, 4, 5; for(int i = 0; i < dum.vec.size(); i++) { cout << dum.vec\[i\]; } return 0;
}
This is one of the neatest tricks I have seen with C++. Simply amazing. C# is fundamentally broken. - Christian Graus
-
C++ trick of the day. As my work day was coming near to close, I was browsing to the source code of Generative Programming book.. I saw some code like this :-
Matrix m = 1, 2, 3 ,4 ,5;
That time I relaized that , operator can also be overloaded. I wrote something like this :-
class dummy
{
public:
std::vector vec;dummy& operator,(const int& val) { vec.push\_back(val); return \*this; } dummy& operator = (const int& val) { vec.push\_back(val); return \*this; }
};
int main(int argc, char* argv[])
{
dummy dum;dum = 1, 2, 3, 4, 5; for(int i = 0; i < dum.vec.size(); i++) { cout << dum.vec\[i\]; } return 0;
}
This is one of the neatest tricks I have seen with C++. Simply amazing. C# is fundamentally broken. - Christian Graus
Evil stuff indeed.
int operator,(int x, int y)
{
return x + y;
}int main(void)
{
printf("This %d is insane!", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
return 0;
}This kind of stuff could break the whole language! Are you sure you can overloard the comma operator without any restrictions? If you were another man, I would kill you where you stand! The line must be drawn here! This far, no further! They must pay for what they've done!
-
?: is the only operator you cannot override in C++ Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeardDon't forget
.
:) --Mike-- Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm -
C++ trick of the day. As my work day was coming near to close, I was browsing to the source code of Generative Programming book.. I saw some code like this :-
Matrix m = 1, 2, 3 ,4 ,5;
That time I relaized that , operator can also be overloaded. I wrote something like this :-
class dummy
{
public:
std::vector vec;dummy& operator,(const int& val) { vec.push\_back(val); return \*this; } dummy& operator = (const int& val) { vec.push\_back(val); return \*this; }
};
int main(int argc, char* argv[])
{
dummy dum;dum = 1, 2, 3, 4, 5; for(int i = 0; i < dum.vec.size(); i++) { cout << dum.vec\[i\]; } return 0;
}
This is one of the neatest tricks I have seen with C++. Simply amazing. C# is fundamentally broken. - Christian Graus
Yah, I've seen some pretty crazy C++ overloads, case in point the MetaKit toolkit (which I've used for a while and is quite nifty). They do all sorts of stuff with commas. Jim Wuerch www.miwasoft.com Quote from my readme files: "This is BETA software, and as such may completely destroy your computer, change the alignment of the planets and invert the structure of the universe."
-
Evil stuff indeed.
int operator,(int x, int y)
{
return x + y;
}int main(void)
{
printf("This %d is insane!", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
return 0;
}This kind of stuff could break the whole language! Are you sure you can overloard the comma operator without any restrictions? If you were another man, I would kill you where you stand! The line must be drawn here! This far, no further! They must pay for what they've done!
C++ goes with the theory that if you give people tools that can be used for evil, people with a reasonable level of skill will find themselves empowered to use them for good. Or as Stroustrup puts it, a language feature should not be judged by the harm it can do in the hands of an inexperienced user, but by it's usefullness when used properly. Someone should have told the C# crowd that. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
Evil stuff indeed.
int operator,(int x, int y)
{
return x + y;
}int main(void)
{
printf("This %d is insane!", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
return 0;
}This kind of stuff could break the whole language! Are you sure you can overloard the comma operator without any restrictions? If you were another man, I would kill you where you stand! The line must be drawn here! This far, no further! They must pay for what they've done!
You can't overload binary operators using built-in types only. At least one should be class/struct. Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
-
C++ trick of the day. As my work day was coming near to close, I was browsing to the source code of Generative Programming book.. I saw some code like this :-
Matrix m = 1, 2, 3 ,4 ,5;
That time I relaized that , operator can also be overloaded. I wrote something like this :-
class dummy
{
public:
std::vector vec;dummy& operator,(const int& val) { vec.push\_back(val); return \*this; } dummy& operator = (const int& val) { vec.push\_back(val); return \*this; }
};
int main(int argc, char* argv[])
{
dummy dum;dum = 1, 2, 3, 4, 5; for(int i = 0; i < dum.vec.size(); i++) { cout << dum.vec\[i\]; } return 0;
}
This is one of the neatest tricks I have seen with C++. Simply amazing. C# is fundamentally broken. - Christian Graus
that was a neat trick, the first time I'm seeing a comma operator overloaded. Thanks for the link too. Kannan
-
You can't overload binary operators using built-in types only. At least one should be class/struct. Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
Oh yeah, forgot about that one. The fact still remains though; you can make a virtual hell for the code maintainers. :) If you were another man, I would kill you where you stand! The line must be drawn here! This far, no further! They must pay for what they've done!
-
C++ goes with the theory that if you give people tools that can be used for evil, people with a reasonable level of skill will find themselves empowered to use them for good. Or as Stroustrup puts it, a language feature should not be judged by the harm it can do in the hands of an inexperienced user, but by it's usefullness when used properly. Someone should have told the C# crowd that. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
Christian Graus wrote: C++ goes with the theory that if you give people tools that can be used for evil, people with a reasonable level of skill will find themselves empowered to use them for good. Hehe, sounds like the start of an excellent sci-fi/fantasy script! Keep elaborating on this one and send a copy to a Hollywood producer.. :) But for the record, I agree with you. If you were another man, I would kill you where you stand! The line must be drawn here! This far, no further! They must pay for what they've done!