DJ Dharme
10/30/2008 12:49:00 PM
On Oct 30, 5:33 pm, arnuld <sunr...@invalid.address> wrote:
> > On Thu, 30 Oct 2008 11:31:39 +0100, Eberhard Schefold wrote:
> > You know that the normal flow of the program goes through main(), so any
> > change should be forbidden. There is another mechanism in C++, though;
> > Objects can reside in a "space" somewhat outside the "normal flow". If
> > you remember what that space is, you should be able to fulfill the
> > requirement.
>
> You are talking about the "classes", which I don't know yet how to write.
> However here is my half-knowledged and uncompilable attempt:
>
> #include <iostream>
>
> class Pre_sentence
> {
> public:
> void print_initialize();
>
> };
>
> class Post_sentence
> {
> public:
> void print_cleanup();
>
> };
>
> Pre_sentence print_begin;
> Post_sentence print_end;
>
> print_begin::print_initialize;
>
> int main()
> {
> std::cout << "Hello World!" << std::endl;
>
> return 0;
>
> }
>
> void Pre_sentence::print_initialize()
> {
> std::cout << "Initialize" << std::endl;
>
> }
>
> void Post_sentence::print_cleanup()
> {
> std::cout << "Clean up" << std::endl;
>
> }
>
> --www.lispmachine.wordpress.com
> my email is @ the above blog.
> Google Groups a.k.a "Spammer's Paradise" is Blocked.
You are so close to the answer, there are two special methods in a
class. If you find them you will know the answer.