[C/C++] enum problem bei funktionen

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von wollknoll, 6. Mai 2007 .

Schlagworte:
Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 6. Mai 2007
    enum problem bei funktionen

    hallo leute, hab ein kleines problem: hier mal meine files:

    main.cpp
    PHP:
    #include <iostream>
    #include "funktionen.h"

    using  namespace  std ;

    int main ()
    {
        
    cout  <<  "Es geht!"  <<  endl ;
        
    cout  <<  createData ();

        return 
    0 ;
    }
    funktionen.cpp
    PHP:
    error_codesE createData ()
    {
        return 
    error_codes ;
    }
    funktionen.h
    PHP:
    #ifndef _FUNKTIONEN_H
    #define _FUNKTIONEN_H

    enum error_codesE
    {
        
    NO_ERROR OUT_OF_MEMORY DATA_CORRUPT DATA_EXIST SIZE_ERROR
    };

    extern error_codesE error_codes ;

    error_codesE createData ();

    #endif

    ich bekomme folgende Fehler:
    PHP:
    1 > d :\ c ++\ blatt5_aufgabe1 \ blatt5_aufgabe1 \ funktionen . cpp ( 1 ) :  error C2146 Syntaxfehler Fehlendes  ';'  vor Bezeichner  'createData'
    1 > d :\ c ++\ blatt5_aufgabe1 \ blatt5_aufgabe1 \ funktionen . cpp ( 1 ) :  error C4430 Fehlender Typspezifizierer  int wird angenommen Hinweis "default-int"  wird von C ++  nicht unterstützt .
    1 > d :\ c ++\ blatt5_aufgabe1 \ blatt5_aufgabe1 \ funktionen . cpp ( 2 ) :  error C4430 Fehlender Typspezifizierer  int wird angenommen Hinweis "default-int"  wird von C ++  nicht unterstützt .
    1 > d :\ c ++\ blatt5_aufgabe1 \ blatt5_aufgabe1 \ funktionen . cpp ( 3 ) :  error C2065 'error_codes' nichtdeklarierter Bezeichner

    hoffe mir kann jemand helfen

    gruß wollknoll
     
  2. 6. Mai 2007
    AW: enum problem bei funktionen

    Du kannst keinen enum als Rueckgabetyp nehmen. Funktionieren tut das zwar aber es ist sinnlos.
     
  3. 6. Mai 2007
    AW: enum problem bei funktionen

    wie keine enum als datentyp, sicher??

    also soll ich ein int zurückgeben?
     
  4. 6. Mai 2007
    AW: enum problem bei funktionen

    Hi !

    Klar kannste enum zurueckgeben ...
    Du hast nur immer das 'enum' vergessen

    Hier mal richtig kurz zusammengeschrieben:
    Code:
    #include <iostream>
    
    using namespace std;
    
    enum error_codesE
    {
     NO_ERROR, OUT_OF_MEMORY, DATA_CORRUPT, DATA_EXIST, SIZE_ERROR
    };
    
    enum error_codesE error_codes;
    enum error_codesE createData (void);
    
    enum error_codesE createData (void)
    {
     return error_codes;
    }
    
    int main (void)
    {
     error_codes = DATA_EXIST;
     cout << "Jetz gehts ;)" << endl;
     cout << createData() << endl;
    
     return 0;
    }
    Also:
    Code:
    enum bla { UND,SO,WEITER };
    enum bla function_die_ein_bla_enum_zurueckgibt (void) { ... }
    typedef enum bla ebla;
    ebla so_kuerz_ich_das_ab (void) { ... }
    Mfg,

    Kolazomai
     
  5. 6. Mai 2007
    AW: enum problem bei funktionen

    dein problem war die fehlende typspezifikation der funktion, c++ nimmt da meines wissens nach dann einfach int an und das führt zu deiner fehlermeldung =)
     
  6. 7. Mai 2007
    AW: enum problem bei funktionen

    hmm, danke.

    bw habt ihr!! merci
     
  7. 7. Mai 2007
    AW: enum problem bei funktionen

    [X] Erledigt.

    ~closed~

    Mfg,

    Kolazomai
     
  8. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.