Re: Concepts of classes and objects in C/C++
In article <1153150808.460836.47710@p79g2000cwp.googlegroups.com>,
"Noah Roberts" <roberts.noah@gmail.com> wrote:
Daniel T. wrote:
... but so obtuse/obfuscated that the OP's teacher
will know at a glance that there is no way that this student of his
created it.
I don't expect most instructors to have it in them to look to hard and
many don't know the language enough (my experience anyway). Besides,
beginner code is regularly obtuse and unreadable having major logic
leaps that are difficult to make sense of...happens because many times
they just keep changing things until it does what the assigment said
without really knowing why. Many teachers might take points for
unreadability but if it works then it passes.
I don't think your plan would work.
You might be right, but I think if the teacher bothers to look at the
code and sees for example, extensive use of features not covered yet (or
even features he doesn't know) or extensive use of boolean operators, he
should be able to tell the difference. As an example, a post from
alt.comp.learn.c-c++ from February:
Dietmar Kuehl wrote:
tiger786 wrote:
?The program should monitor a possibly infinite stream of characters
from the keyboard (standard input). ?If it detects the sequence "ccc"
it outputs a "0". ?If it detects the sequence "cdc" it outputs a "1".
DO NOT detect sequences within sequences. ?The program should exit
cleanly when it detects an End Of Input.
The others who think that you should do your homework assignment
alone are just spoilsports! The obvious solution to the above
problem is rather simple:
? #include <iostream>
? #include <iterator>
? #include <algorithm>
? struct __ {
? ? enum { _0 = 0x636363 };
? ? __(): _() {}
? ? void operator()(unsigned char _1) {
? ? ? _ = ((_ = (_ & 0xffff) << 8 | _1) == _0 || _ == _0 + 0x100)
? ? ? ? && std::cout << (_0 < _)? 0: _;
? ? }
? ? unsigned long _;
? } _;
? int main()
? {
? ? std::for_each(std::istreambuf_iterator<char>(std::cin),
? ? ? ? ? ? ? ? ? std::istreambuf_iterator<char>(), _);
? ? std::cout << "\n";
? }
Of course, you should understand the program before handing it in
because it would be a really stupid idea not to do your homework!
Several of us also posted answers that made extensive use of #define,
but the above was by far the most ingenious, IMHO.