Results 1 to 19 of 19

Thread: Executing C++ before and after main()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Executing C++ before and after main()

    Could we see your custom allocator/deallocator and how you use it? Maybe you can show us where exactly you get the segfaults...

    Regards

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Executing C++ before and after main()

    Well, I dont if I'm correct. I was asked the same question by my friend, How to call display a string before main() and another string after main()...

    Something like
    Qt Code:
    1. int main()
    2. {
    3. cout<<"Love";
    4. }
    To copy to clipboard, switch view to plain text mode 
    Now without touching main() I need to display "I Love You"
    So the solution is something like this
    Qt Code:
    1. class A
    2. {
    3. public:
    4. A(){ cout<< "I"; }
    5. ~A() { cout<<"You"; }
    6. };
    7. A a;
    8. int main()
    9. {
    10. cout<<"Love";
    11. }
    To copy to clipboard, switch view to plain text mode 

    Here 'I' is displayed before main and 'You' after main.. Do you want something like this???

    //I have not tested above code so might be incorrect....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.