Jump to content

Debug Code Blocks

- - - - -

  • Please log in to reply
6 replies to this topic

#1
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
How the watches of CodeBlocks show variables from within a class?

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Um...care to clarify what exactly you mean by that? What would you like to do?
sudo rm -rf /

#3
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
Debug shows:
Local Variables
Function Arguments


How do I watche the variables that were created within the class ?

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
You watch the class variable and should be able to expand it to see the member variables. For example:
void foo(OtherClass& bar)
{
    MyClass *baz = new MyClass();
    // other stuff
}

You would watch bar, the function argument, and baz​, the local variable. I haven't used this in a while, but if it's anything like Visual Studio, that's how it'll work.
sudo rm -rf /

#5
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

dargueta said:

You watch the class variable and should be able to expand it to see the member variables. For example:
void foo(OtherClass& bar)
{
    MyClass *baz = new MyClass();
    // other stuff
}

You would watch bar, the function argument, and baz​, the local variable. I haven't used this in a while, but if it's anything like Visual Studio, that's how it'll work.

I'm talking about private variables

class Test{
 private:
       int var;
  .
  .
  .

I have Test.cpp that handles the variable var. How can I watches this variable ?

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Yes, that's exactly what I meant. Going with my example:

1) While debugging, right-click on baz.
2) Select Watch 'baz'
3) In the Watch window you'll see something like baz = (MyClass *)0x804b008.
4) Right-click on that, and select Dereference 'baz'.

Beneath that will appear an expandable tree with all of the member variables, including the private ones.
sudo rm -rf /

#7
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

dargueta said:

Yes, that's exactly what I meant. Going with my example:

1) While debugging, right-click on baz.
2) Select Watch 'baz'
3) In the Watch window you'll see something like baz = (MyClass *)0x804b008.
4) Right-click on that, and select Dereference 'baz'.

Beneath that will appear an expandable tree with all of the member variables, including the private ones.

Ok. Thank you




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users