ich finde den Fehler in der Classenerstellung nicht :(



  • Hi
    ich habe ein kleinesProblem.
    Eine Klasse ... normal erstellt mit private und public deklerationen.
    Soweit ich das beurteilen kann müsstze diese Klasse eigendlich richtig erstellt worden sein, aber die compilerfehlerliste ist endlos.
    Könnt ihr mir da helfen?

    struct attributes
    {
    	short int iStrength;
    	short int iDefence;
    	short int iVitality:
    	short int iIntelegence;
    	short int iCharisma;
    	short int iAgility;
    	short int iDexterity;	
    };
    
    class PLAYER
    {
    public:
    	void AddExp(int iExp);
    	void LooseExp();
    	int  GetExp();
    
    	int  GetStrength();
    	int  GetDefence();
    	int  GetVitality();
    	int  GetIntelegence();
    	int  GetCharisma();
    	int  GetAgility();
    	int  GetDexerity();
    
    private:
    	short int  iExperience;
    	short int  iBaseLevel;
    	short int  iJobLevel;
    
    	//ATTRIBUTE
    	attributes attribute;
    	attributes temporaryAttribute;
    	attributes jobBasedAttribute;	
    
    	short int  iNumberOfUpLevels;
    
    	short int  iHealthPoints;
    	short int  iSkillPoints;
    
    	short int  iJobType;
    
    	char Zeichen, WhatToDo;
          	string Dateiname, Zeile;
    	ifstream Eingabedatei;
    
    };
    
    void PLAYER::AddExp(int iExp) { iExperience = iExperience + iExp; };
    
    void PLAYER:LooseExp() { iExperience = iExperience - (iExperience / 100); };
    
    int PLAYER::GetExp() 		{ return( iExperience ); };
    
    int PLAYER::GetStrength();	{ return( attribute.Strength    + temporaryAttribute.Strength    + jobBasedAttribute.Strength    ); };
    int PLAYER::GetDefence();	{ return( attribute.Defence     + temporaryAttribute.Defence     + jobBasedAttribute.Defence     ); };
    int PLAYER::GetVitality();	{ return( attribute.Vitality    + temporaryAttribute.Vitality    + jobBasedAttribute.Vitality    ); };
    int PLAYER::GetIntelegence();	{ return( attribute.Intelegence + temporaryAttribute.Intelegence + jobBasedAttribute.Intelegence ); };
    int PLAYER::GetCharisma();	{ return( attribute.Charisma    + temporaryAttribute.Charisma    + jobBasedAttribute.Charisma    ); };
    int PLAYER::GetAgility();	{ return( attribute.Agility     + temporaryAttribute.Agility     + jobBasedAttribute.Agility     ); };
    int PLAYER::GetDexerity();	{ return( attribute.Dexerity    + temporaryAttribute.Dexerity    + jobBasedAttribute.Dexerity    ); };
    

    c:\Datein\c++\mmporpg>emacs server.h

    c:\Datein\c++\mmporpg>bcc32 main.cpp
    Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
    main.cpp:
    Error E2188 player.h 6: Expression syntax
    Error E2303 player.h 54: Type name expected
    Error E2139 player.h 54: Declaration missing ;
    Error E2303 player.h 55: Type name expected
    Error E2139 player.h 55: Declaration missing ;
    Error E2449 player.h 61: Size of 'PLAYER' is unknown or zero
    Error E2141 player.h 61: Declaration syntax error
    Error E2333 player.h 66: Class member 'PLAYER::GetStrength()' declared outside its class
    Error E2040 player.h 66: Declaration terminated incorrectly
    Error E2333 player.h 67: Class member 'PLAYER::GetDefence()' declared outside its class
    Error E2040 player.h 67: Declaration terminated incorrectly
    Error E2333 player.h 68: Class member 'PLAYER::GetVitality()' declared outside its class
    Error E2040 player.h 68: Declaration terminated incorrectly
    Error E2333 player.h 69: Class member 'PLAYER::GetIntelegence()' declared outside its class
    Error E2040 player.h 69: Declaration terminated incorrectly
    Error E2333 player.h 70: Class member 'PLAYER::GetCharisma()' declared outside its class
    Error E2040 player.h 70: Declaration terminated incorrectly
    Error E2333 player.h 71: Class member 'PLAYER::GetAgility()' declared outside its class
    Error E2040 player.h 71: Declaration terminated incorrectly
    Error E2333 player.h 72: Class member 'PLAYER::GetDexerity()' declared outside its class
    Error E2040 player.h 72: Declaration terminated incorrectly
    *** 21 errors in Compile ***



  • was sagt dir die erste fehlermeldung?
    dass du in zeile 6 mal nachschauen sollst.
    was ist der fehler in zeile 6?
    da ist ein doppelpunkt statt einem semikolon.

    berichtige das erstmal und dann compile nochmal.
    damit verschwinden vielleicht schon einige folgefehler.



  • Ich liebe diese Fehler 🙂
    aber es war nur der eine, die restlichen 20 sind noch da.



  • void PLAYER::AddExp(int iExp) { iExperience = iExperience + iExp; }
    
    void PLAYER:LooseExp() { iExperience = iExperience - (iExperience / 100); }
    
    int PLAYER::GetExp() 		{ return( iExperience ); }
    
    int PLAYER::GetStrength()	{ return( attribute.Strength    + temporaryAttribute.Strength    + jobBasedAttribute.Strength    ); }
    int PLAYER::GetDefence()	{ return( attribute.Defence     + temporaryAttribute.Defence     + jobBasedAttribute.Defence     ); }
    int PLAYER::GetVitality()	{ return( attribute.Vitality    + temporaryAttribute.Vitality    + jobBasedAttribute.Vitality    ); }
    int PLAYER::GetIntelegence()	{ return( attribute.Intelegence + temporaryAttribute.Intelegence + jobBasedAttribute.Intelegence ); }
    int PLAYER::GetCharisma()	{ return( attribute.Charisma    + temporaryAttribute.Charisma    + jobBasedAttribute.Charisma    ); }
    int PLAYER::GetAgility()	{ return( attribute.Agility     + temporaryAttribute.Agility     + jobBasedAttribute.Agility     ); }
    int PLAYER::GetDexerity()	{ return( attribute.Dexerity    + temporaryAttribute.Dexerity    + jobBasedAttribute.Dexerity    ); }
    

    Und so wie's aussieht hast du std:: für string und ifstream (wofür den?) vergessen.



  • Mpfh, wiso habe ich das nicht selber gesehen ...?
    danke

    waren noch ein Paar Buchwechselverstapler drinne, dsa gab zwischendurch nochmal weitere 21 fehler 🙂

    Aber nun funktionierts

    "wofür den?"
    damit will ich die einzelnen Attribute aus einer Datei auslesen. Kommt dann alles in den Konstruktor rein.


Anmelden zum Antworten