Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » inhalte einer klasse in einer anderen verwenden

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: [ 1 ] [ 2 ] [ 3 ] > 4 < [ 5 ]
030
29.08.2003, 14:41 Uhr
virtual
Sexiest Bit alive
(Operator)


Kerl! Du wunderst Dich auch noch?
Du machst wenn das bind schief geht ein exit. Verwende exit nie nie nie einfach so, ohne jemanden ein Wort davon zu sagen. (In klassen hat exit eh meist nichts verloren. eigentlich nie).
Der saubere Weg: wirf das ne exception im constructor und fange sie da, wo du construiert hast. Dann kannst du auch sauber drauf reagieren.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
031
29.08.2003, 14:44 Uhr
~darthvader
Gast


Hab es jetzt auch gesehen, wunder mich nicht. Hab in dem moment nicht auf den Konstruktor geschaut, sondern mehr auf die Testausgaben.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
032
29.08.2003, 14:44 Uhr
virtual
Sexiest Bit alive
(Operator)


Also:

C++:
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "hwstat.h"


void Form1::init()
{
    // Socket einrichten fuer UDP
   if (0 > (sfd = socket (AF_INET, SOCK_DGRAM, 0))) {
        [b]throw std::runtime_error("error: socket");[/b]
    }

    // Addresse und Port des Servers
    memset (&srv_ip, 0, sizeof(srv_ip));
    srv_ip.sin_family = AF_INET;
    srv_ip.sin_port   = htons (PORTNR);
    inet_aton (SERVER_IP, &srv_ip.sin_addr);

    // Bind
    if (0 > bind (sfd, (struct sockaddr *) &srv_ip, sizeof(srv_ip))) {
        close (sfd);
        [b]throw std::runtime_error("error: bind");[/b]
    }


    printf ("Server waiting for data ...\n");


}
...

try
{
   Form1 a;
}
catch (std::exception& e)
{
    std::cerr<<e.what()<<std::endl;
    // Thread nun beenden, zB durch return, wenn du direkt in threadfkt. bist
}


--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
033
29.08.2003, 14:58 Uhr
~darthvader
Gast


muss ich für runtime_error noch was includieren? bei mir ist undeclared.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
034
29.08.2003, 15:00 Uhr
virtual
Sexiest Bit alive
(Operator)


#include <stdexcept>
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
035
29.08.2003, 15:20 Uhr
~darthvader
Gast


Nach make sieht bei mir das so aus:


C++:
g++ -c -pipe -Wall -W -I/usr/include/freetype2 -O2 -march=i386 -mcpu=i686 -fno-exceptions  -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -I/usr/lib/qt3-gcc2.96/include -I.ui/ -I/home/andreas/qtneu -I.moc/ -I/usr/lib/qt3-gcc2.96/mkspecs/default -o .obj/anzeige.o .ui/anzeige.cpp
In file included from .ui/anzeige.cpp:21:
/home/andreas/qtneu/anzeige.ui.h: In method `void Form1::init ()':
/home/andreas/qtneu/anzeige.ui.h:58: exception handling disabled, use
-fexceptions to enable
make: *** [.obj/anzeige.o] Error 1





Wie schalte ich die exception-unterstützung ein??
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
036
29.08.2003, 15:24 Uhr
~darthvader
Gast


Schätze da muss wieder eine Option eingeschaltet werden aber wie?
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
037
29.08.2003, 15:27 Uhr
virtual
Sexiest Bit alive
(Operator)


Steht doch da: -fexception als Compileroption mit übergeben.

Generell empfiehlt sich ein Upgrade auf einen gcc 3.x, wenn Du mit C++ arbeitest. Ich benutze zwar auch noch den gcc 2.95, aber nur noch für C.
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
038
29.08.2003, 15:30 Uhr
~darthvader
Gast


ich übersetz mit make einfach, wie kann ich hier die compileroption benutzen?

Vielen Dank für deine Hilfe!
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
039
29.08.2003, 15:47 Uhr
virtual
Sexiest Bit alive
(Operator)


Wo kommt denn das Makefile her?
--
Gruß, virtual
Quote of the Month
Ich eß' nur was ein Gesicht hat (Creme 21)
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: [ 1 ] [ 2 ] [ 3 ] > 4 < [ 5 ]     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: