Re: [Dev-C++] segmentation fault at runtime
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Black E. <bla...@ea...> - 2004-12-15 21:42:49
|
It's tricky but I think I got it
In fact I am returning a pointer to m_pSrv which is a pointer itself, rathe=
r=20
than the adress of the class, right ?
What could have worked is if m_pSrv was the class and that I returned &m_pS=
rv,=20
the adress of the class.
But I've done like this :
KviIrcServer beConsole::server()
{
qDebug("returning server");
return *m_pSrv;
}
Thanks for help !
Le mercredi 15 D=E9cembre 2004 22:06, Alfred P. Reaud a =E9crit :
> Hi Black Eagle,
>
> It could be that you are returning the address of m_pSrv rather than it's
> contents. You've declared m_pSrv as a pointer to a KviIrcServer class.=20
> However, in server(), you return m_pSrv, rather than it's contents *m_pSr=
v.
> server() is declared as returning a pointer to the class, which is the
> value of m_pSrv, not it's address.
>
> Hope that makes sense!
>
> Black Eagle <bla...@ea...> wrote:
>
> Hi guys!
>
> I got a problem at run time, when using a pointer in a function.
>
> The error is in the function KviIrcServer* server() at line : return
> m_pSrv;
>
> In all other functions I got no problem with this variable. It is another
> class that tries to call this function, it's the friendclass beChannel
>
>
> <snip>
> class KviIrcServer;
> <snip>
> KviIrcServer* server();
> <snip>
> private :
> KviIrcServer * m_pSrv;
> <snip>
> KviIrcServer* beConsole::server()
> {
> qDebug("returning server");
> return m_pSrv;
> }
> <snip>
>
>
>
>
> Alfred P. Reaud
|