Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 605945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:12:05+00:00 2026-05-13T17:12:05+00:00

In Eclipse I can override the toString() method of an Object to pretty print

  • 0

In Eclipse I can override the toString() method of an Object to pretty print it. This is especially useful because during a debug sessions as I can click on a variable and see the object in a human readable form.

Is there any kind of equivalent for C++ during a gdb session. I’m also open to any IDEs that can emulate this behavior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:12:06+00:00Added an answer on May 13, 2026 at 5:12 pm

    In gdb, print command prints the contents of the variable. If you are using any IDE for C++, eg. Netbeans, Eclipse, VC++ then pointing on the variable shows the content.

    EDIT: See if the below code is what you are looking for.

    #include <string>
    using std::string;
    
    #define magic_string(a) #a
    
    template<typename T>
    class Object_C
    {
    private:
        virtual string toString_Impl()
        {
            return magic_string(T);
        }
    
    public:
        Object_C(void)
        {
        }
        virtual ~Object_C(void)
        {
        }
        string toString()
        {
            return toString_Impl();
        }
    };
    
    class Base_C :
        public Object_C<Base_C>
    {
    private:
        string toString_Impl()
        {
            char str[80] = "";
            sprintf_s(str, 79, "Base.x:%d\n", x_);
            return string(str);     
        }
    private:
        int x_;
    
    public:
        Base_C(int x = 0) : x_(x) { }
        ~Base_C(void);
    };
    
    void ToStringDemo()
    {
        Base_C base;
        cout << base.toString() << endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you override method in java without using annotations? Because eclipse doesn't support it
In Eclipse, can I find which methods override the method declaration on focus now?
How can I write a method and force the subclasses to override this method.
I know that eclipse can do this, can Intellij via the new Android support
Eclipse is offering final but I can't increase the i variable. @Override public void
I am already desperated, because I can't fix my User Interface in Eclipse RCP.
Eclipse 3.5 indents this code correctly: addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e)
I want to override a method that has an parameter of type Object :
I wish to print a Stack<Integer> object as nicely as the Eclipse debugger does
Eclipse can be configured to ignore unavoidable generic type problems when setting the preferences

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.