C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Speicherzugriffsfehler...ableiten von ostream

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun May 14, 2006 12:22 pm    Post subject: Speicherzugriffsfehler...ableiten von ostream Reply with quote



Hallo Coders!

Wenn ich von ostream direkt ableite und eine entsprechende instanz
nutze,
dann krachts auf meiner linux schüssel.

-----------
class XStream : public ostream
{

};

XStream xout;
....

void f()
{
xout << "hallo" << "\n" ;
}
-----------
programm wird übersetzt und gebunden.
habe laufzeitfehler:
"Speicherzugriffsfehler"

kann mir einer sagen wieso ?

danke für eure mühe!

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Bob Hairgrove
Guest





PostPosted: Sun May 14, 2006 4:21 pm    Post subject: Re: Speicherzugriffsfehler...ableiten von ostream Reply with quote



On 14 May 2006 04:25:25 -0700, olaf.kliche (AT) gmx (DOT) net wrote:



Quote:
Hallo Coders!



Wenn ich von ostream direkt ableite und eine entsprechende instanz

nutze,

dann krachts auf meiner linux schüssel.



-----------

class XStream : public ostream

{



};



XStream xout;

...



void f()

{

xout << "hallo" << "\n" ;

}

-----------

programm wird übersetzt und gebunden.

habe laufzeitfehler:

"Speicherzugriffsfehler"



kann mir einer sagen wieso ?



danke für eure mühe!



Ohne den minimal kompilierbaren Code zu sehen, kann kein Mensch etwas

Schlüssiges dazu sagen. Bei mir kompiliert dieser Code jedenfalls

nicht!



--

Bob Hairgrove

NoSpamPlease (AT) Home (DOT) com


--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Hans-Peter huth
Guest





PostPosted: Sun May 14, 2006 6:30 pm    Post subject: Re: Speicherzugriffsfehler...ableiten von ostream Reply with quote



On 14 May 2006 04:25:25 -0700
olaf.kliche (AT) gmx (DOT) net wrote:

Quote:
Hallo Coders!

Wenn ich von ostream direkt ableite und eine entsprechende instanz
nutze,
dann krachts auf meiner linux schüssel.

-----------
class XStream : public ostream
{

};

XStream xout;
...

void f()
{
xout << "hallo" << "\n" ;
}
-----------
programm wird übersetzt und gebunden.
habe laufzeitfehler:
"Speicherzugriffsfehler"


Ist denn xout schon initialisiert wenn du das erste mal darauf zugreifst?
So wie du das oben angedeutet hast, ist xout ein globales Object und AFAIK
ist nicht garantiert wann da der Standardkonstruktor aufgerufen wird.
Könnte man z.B. so beheben (ungetestet):

....
// globales singleton per function mit statischem Objekt
XStream& xout() {
static XStream xout;
return xout;
}

....
xout() << "hallo" << endl;



Gruß HPH

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Bob Hairgrove
Guest





PostPosted: Sun May 14, 2006 9:23 pm    Post subject: Re: Speicherzugriffsfehler...ableiten von ostream Reply with quote

On Sun, 14 May 2006 17:29:01 +0200, Bob Hairgrove

<invalid (AT) bigfoot (DOT) com> wrote:



Aus irgendeinem Grund verdoppelt diese NG alle Zeilenschaltungen bei

meinen Posts ... andere NG zeigen sie normal an. Liegt das am Server?

Ich benutze seit eh und je den Forté Free Agent.



--

Bob Hairgrove

NoSpamPlease (AT) Home (DOT) com


--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
kanze
Guest





PostPosted: Mon May 15, 2006 2:23 pm    Post subject: Re: Speicherzugriffsfehler...ableiten von ostream Reply with quote

olaf.kliche (AT) gmx (DOT) net wrote:

Quote:
Wenn ich von ostream direkt ableite und eine entsprechende
instanz nutze, dann krachts auf meiner linux schüssel.

-----------
class XStream : public ostream
{
};

XStream xout;
...

void f()
{
xout << "hallo" << "\n" ;
}
-----------
programm wird übersetzt und gebunden.
habe laufzeitfehler:
"Speicherzugriffsfehler"

kann mir einer sagen wieso ?

Wie hast du den ostream initialisiert? Ohne das zu wissen, kann
man überhaupt nichts sagen.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Guest






PostPosted: Wed May 24, 2006 11:26 am    Post subject: Re: Speicherzugriffsfehler...ableiten von ostream Reply with quote

uuups - sorry, das ich mich jetzt erst wieder melde!

erst mal danke für eure antworten !
Quote:
Wie hast du den ostream initialisiert? Ohne das zu wissen, kann
man überhaupt nichts sagen.

mmmmh, kann man das denn nicht sehen ?

XStream xout;
//global !


void f()
{
xout << "hallo" << "\n" ;
}

-------------------
ich weiss, das das dirty ist!
aber funktionieren müsste es trotzdem, meine ich.
und da würde ich halt gerne wissen, warum's nicht tut.

da der c++ compiler ja alles von vorne nach hinten durchgeht,
und er zuerst auf die deklarierte klasse trifft, dann eine object
instanziert
und zuletzt in der funktion f aufruft, müsste es ja gehen.

wenn ich eine klasse X habe und ein paar zeilen später ein object x,
dann kann ich noch ein paar zeilen später problemlos mit x arbeiten.

ich vermute eher,
das man nicht so einfach von XStream (unter linux) ableiten kann.

oder ?

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.