I agree, your print statement should work.
I get the same mesage and unfortanately have no idea how to get around it.
The documentation indicates to me that the print statement should work.

"Chih-Wei(Jim) Chang" wrote:

> Hi,
>
>         Sorry if this is not a bug. But this is something bothers me a lot
>         these days.
>
>         I recently switched my OS from Solaris to Mandrake Linux 7.0.
>         It seems I have some problem debugging my c++ code using gdb. Here is a
>         sample code:
> ------------------------------------------------------------------------
> #include <iostream.h>
> class MyClass
> {
>         private:
>         int a;
>         public:
>         MyClass() {a = 1;}
>         int Get_a() {return a;}
> };
> main()
> {
>         MyClass inst;
>         cout << inst.Get_a() << endl;
> }
> ------------------------------------------------------------------------
>         After compiling the code using "g++ -g main.cxx", I launch gdb by
>         "gdb a.out". And start tracing the code:
> ------------------------------------------------------------------------
> [cwchang@localhost ~/tmp]$ g++ -g main.cxx
> [cwchang@localhost ~/tmp]$ a.out
> 1
> [cwchang@localhost ~/tmp]$ gdb a.out
> GNU gdb 19991116
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i586-mandrake-linux"...
> (gdb) b main
> Breakpoint 1 at 0x8048656: file main.cxx, line 16.
> (gdb) r
> Starting program: /home/cwchang/tmp/a.out
>
> Breakpoint 1, main () at main.cxx:16
> 16              MyClass inst;
> (gdb) n
> 18              cout << inst.Get_a() << endl;
> (gdb) p inst.Get_a()
> Cannot resolve method MyClass::Get_a to any overloaded instance
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> (gdb) ptype inst
> type = class MyClass {
>   private:
>     int a;
>
>   public:
>     MyClass & operator=(MyClass const &);
>     MyClass(MyClass const &);
>     MyClass(void);
>     int Get_a(void);
>     int Get_b(int);
> }
> (gdb) info source
> Current source file is main.cxx
> Compilation directory is /home/cwchang/tmp/
> Located in /home/cwchang/tmp/main.cxx
> Contains 22 lines.
> Source language is c++.
> Compiled with stabs debugging format.
> (gdb)
> ----------------------------------------------------------------------
>
>         "Cannot resolve method MyClass::Get_a to any overloaded instance"
>         What does this mean? It seems I cannot not execute the expression
>         because gdb cannot find the corresponding reference. I have no
>         problem debugging this piece of code on my Solaris machine (the
>         command "p inst.Get_a()" have no problem get executed) Is this
>         a machine-dependent issue?
>
>         Any idea? Thanks in advance.
>
> Jim

--
Regards,
                 Paul Hardiman
            InterMedia, Inc (Colorado)
         Informations Systems Consulting
303-581-0606, Fax 581-0506, [EMAIL PROTECTED]


Reply via email to