[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Can anyone give me a push in the right direction?
From:       Emily Ezust <gexcfxyy () umail ! corel ! com>
Date:       2000-02-24 17:34:11
[Download RAW message or body]

Hi Peter!
May we see the main program - or the part that creates the object
in question? It's difficult to tell exactly, but I suspect there's
a non-initialized pointer involved somewhere.

Also, I'd like to strongly encourage you not to make data public
(as you did with bits). In object-oriented programming, you want 
to restrict access to the data - it makes things easier to maintain
and debug, and if you later decide to change your implementation, 
you don't have to change the entire app. Look up "encapsulation"
or "data hiding" in a C++ book if you need some more specific 
arguments and examples for this.

Peter Thorstenson wrote:
> 
> Hi!
> 
> I'm learning C++ and have been using kdevelop since 2 months.
> My application for KDE 1.X is getting along over my expectations. That means
> good.
> However, three days ago I ran in to a problem that does not let me continue.
> Any help is appreciated.
> 
> Problem description:
> A added a new class to my project. In this class I declare a variable as
> public.
> This means that any other class should be able to set or alter the value of
> this variable.
> I works fine if I do it from my view-class. There I can alter the value of
> the variable without problems.
> BUT if I try to alter the value from a class that no qt or kde things in it,
> the program quits directly with errors.
> The program compiles fine in both cases. No complaints about missing
> declarations.
> I use the same declaration of the objects: mp3_header header and the same
> way lines to alter the variable.
> In the class I call mp3_headers from:
> 
> .h: **************************
> #include >mp3_header.h>
> :
> :
> :
> private:
>   mp3_header header;
> 
> .cpp: *********************
> header.Load();
> 
> The funny thing is that I can't even set the variable from inside it's own
> class...
> 
> I must be making a basic misstake. To me it looks so silly, yet I'm not able
> to solve this problem.
> Is there anyone that can give me a push in the right direction.........?
> 
> Thanks in advance....
> 
> Peter Torstenson
> Rio de Janeiro, 35 degrees Celcius.
> 
> code and debug info follows........
> ********* mp3_header.h *****************
> #ifndef MP3_HEADER_H
> #define MP3_HEADER_H
> 
> class mp3_header {
> 
>   public:
>     int bits;
>     mp3_header();
>     ~mp3_header();
> 
>     // loads the header
>     void Load();
> 
> };
> 
> #endif
> *****************************************
> 
> ******** mp3_header.cpp ************
> #include "mp3_header.h"
> 
> mp3_header::mp3_header(){
> }
> mp3_header::~mp3_header(){
> }
> 
> void mp3_header::Load(){
>  /* Here I try to set the variable:bits
>     This is where the program exits*/
>   bits=1;
> }
> *****************************************
> From de debug:
> (I do not understand much of this..)
> 
> MEMORY
> 0x0: Cannot access memory at address 0x0.
> 
> DISASSEMBLE
> Dump of assembler code for function readInfo__8mp3_filePCcPc:
> 0x80577c0 <readInfo__8mp3_filePCcPc>: push   %ebp
> 0x80577c1 <readInfo__8mp3_filePCcPc+1>: mov    %esp,%ebp
> 0x80577c3 <readInfo__8mp3_filePCcPc+3>: sub    $0x14,%esp
> 0x80577c6 <readInfo__8mp3_filePCcPc+6>: push   %edi
> 0x80577c7 <readInfo__8mp3_filePCcPc+7>: push   %esi
> 0x80577c8 <readInfo__8mp3_filePCcPc+8>: push   %ebx
> 0x80577c9 <readInfo__8mp3_filePCcPc+9>: push   $0xc8
> 0x80577ce <readInfo__8mp3_filePCcPc+14>: call   0x804c6e8 <__builtin_new>
> 0x80577d3 <readInfo__8mp3_filePCcPc+19>: add    $0x4,%esp
> 0x80577d6 <readInfo__8mp3_filePCcPc+22>: mov    %eax,%eax
> 0x80577d8 <readInfo__8mp3_filePCcPc+24>: mov    %eax,0xffffffec(%ebp)
> 0x80577db <readInfo__8mp3_filePCcPc+27>: push   $0x1b4
> 0x80577e0 <readInfo__8mp3_filePCcPc+32>: push   $0xa1
> 0x80577e5 <readInfo__8mp3_filePCcPc+37>: mov    0xc(%ebp),%eax
> 0x80577e8 <readInfo__8mp3_filePCcPc+40>: push   %eax
> 0x80577e9 <readInfo__8mp3_filePCcPc+41>: push   $0x1
> 0x80577eb <readInfo__8mp3_filePCcPc+43>: mov    0xffffffec(%ebp),%ebx
> 0x80577ee <readInfo__8mp3_filePCcPc+46>: push   %ebx
> 0x80577ef <readInfo__8mp3_filePCcPc+47>: call   0x804c708
> <__8ifstreamiPCcii>
> 0x80577f4 <readInfo__8mp3_filePCcPc+52>: add    $0x14,%esp
> 0x80577f7 <readInfo__8mp3_filePCcPc+55>: mov    %eax,%edi
> 0x80577f9 <readInfo__8mp3_filePCcPc+57>: jmp    0x8057805
> <readInfo__8mp3_filePCcPc+69>
> 
> REGISTERS
> eax            0x8064ef8 134631160
> ecx            0x0 0
> edx            0x0 0
> ebx            0x0 0
> esp            0x7ffff648 0x7ffff648
> ebp            0x7ffff668 0x7ffff668
> esi            0x0 0
> edi            0x80b0818 134940696
> eip            0x8057959 0x8057959
> eflags         0x10206 66054
> cs             0x23 35
> ss             0x2b 43
> ds             0x2b 43
> es             0x2b 43
> fs             0x0 0
> gs             0x0 0
> 
> LIBRARIES
> From        To          Syms Read   Shared Object Library
> 0x2aac1000  0x2ab15dcc  Yes         /usr/lib/libkfile.so.2
> 0x2ab16000  0x2ab25cf0  Yes         /usr/lib/libkfm.so.2
> 0x2ab26000  0x2ac2ebe0  Yes         /usr/lib/libkdeui.so.2
> 0x2ac2f000  0x2acdcaac  Yes         /usr/lib/libkdecore.so.2
> 0x2acdd000  0x2aeee1c0  Yes         /usr/lib/libqt.so.1
> 0x2aeef000  0x2aefb980  Yes         /usr/X11R6/lib/libXext.so.6
> 0x2aefd000  0x2afabf88  Yes         /usr/X11R6/lib/libX11.so.6
> 0x2afac000  0x2aff1e30  Yes         /usr/lib/libstdc++.so.2.9
> 0x2affa000  0x2b017f08  Yes         /lib/libm.so.6
> 0x2b018000  0x2b11269c  Yes         /lib/libc.so.6
> 0x2aaab000  0x2aabf9b0  Yes         /lib/ld-linux.so.2

-- 
Emily Ezust, emilye@corel.com
Corel Corporation
(613)728-0826, x 5936
-- 
The address in the headers is not the poster's real email address.  Do not send
private mail to the poster using your mailer's "reply" feature.  CC's of mail 
to mailing lists are OK.  Problem reports to "postmaster@umail.corel.com".  
The poster's email address is "emilye@corel.com".

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic