2017-02-24 17 views
0

Beim Ausführen des folgenden Codes erhalte ich einen Fehler, der besagt, dass "Form" kein Typname ist. Kann jemand helfen?Variable vom Typ enum ist kein Typname?

#include <iostream> 

using namespace std; 

enum triangleType {scalene, isosceles, equilateral, noTriangle};  //Define an enumeration of possible triangle types 
triangleType shape; 

shape triangleShape(int a, int b, int c); //Declare prototype for function that calculates triangle type and returns enumeration 

int main() 
{  
    return 0; 
} 
+5

'shape' ist eine Variable, deren Typ' triangleType', es ist kein Typname. – Barmar

+0

Ahh ich verstehe. Was sollte die Funktion dann zurückgeben? DreieckTyp? – Froobyflake

+0

Ja, das ist der Typname. – Barmar

Antwort

0

Dies sollte Ihr Problem mit den Fehlermeldungen beheben:

enum triangleType {scalene, isosceles, equilateral, noTriangle}; 
// triangleType shape; // shape here is a declared variable of type triangleType. 

// triangleType is the type which is an enumerated type or integral type so this is valid. 
triangleType triangleShape(int a, int b, int c); 
// having a function to return a variable and not a type will generate an error 
// shape triangleShape(int a, int b, int c); // error - shape is not declared as type. 

int main() 
{  
    return 0; 
} 
Verwandte Themen