Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 22:35

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++] Vererbungsproblem

Discussion on [C++] Vererbungsproblem within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2012
Posts: 7
Received Thanks: 0
Exclamation [C++] Vererbungsproblem [Solved]

Wie bereits im Titel geschrieben habe ich ein Problem mit der Vererbung in C++

Object.hpp
Code:
#ifndef OBJECT_HPP
#define OBJECT_HPP
#include<SFML/System.hpp>
#include<SFML/Window.hpp>
#include<SFML/Graphics.hpp>
#include"MainResources.hpp"

class Object : public sf::Sprite{
private:[INDENT]float Temperature;
float Contamination;
sf::Vector2f Size;
sf::IntRect Area;
[/INDENT]public:[INDENT]void SetTemperature(float Temperature);
void SetContamination(float Contamination);
void SetSize(sf::Vector2f Size);
float *GetTemperature();
float *GetContamination();
sf::Vector2f *GetSize();
void ComputeScale();
void ComputeArea();
sf::IntRect *GetArea();
[/INDENT]};

#endif // OBJECT_HPP


Person.hpp

Code:
#ifndef PERSON_HPP
#define PERSON_HPP
#include<SFML/System.hpp>
#include<SFML/Window.hpp>
#include<SFML/Graphics.hpp>
#include"Object.hpp"

class Person : public Object{
private:[INDENT]int Health;
int Stamina;
int Magicka;
sf::View Sight;
sf::IntRect SightArea;
[/INDENT]public:[INDENT]void SetHealth(int Health);
void SetStamina(int Stamina);
void SetMagicka(int Magicka);
int *GetHealth();
int *GetStamina();
int *GetMagicka();
[/INDENT]};

#endif // PERSON_HPP
Dabei bekomme ich immer folgende Fehlermeldung:
"Person.hpp:8: Fehler:expected class-name before '{' token"

Letztendlich konnte die Klasse "Object" ja auch von "sf::Sprite" erben.
Ich weiß einfach nicht was ich falsch gemacht habe.

Danke im Voraus für die Hilfe
ColdFreezer is offline  
Old 04/11/2012, 00:59   #2
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Code-Tags bitte und vernünftig einrücken. Danke.
xNopex is offline  
Old 04/11/2012, 01:08   #3
 
elite*gold: 0
Join Date: Feb 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by xNopex View Post
Code-Tags bitte und vernünftig einrücken. Danke.
Okay ich habe jetzt den Code jetzt eingerückt. Kannst du mir bitte kurz sagen was du mit "Code-Tags" meinst? Weiß nicht was das ist/was du damit meinst

Edit: Ich habe jetzt auch die Codeform gemacht, glaube du hast das gemeint
ColdFreezer is offline  
Old 04/11/2012, 01:54   #4


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Liegt Object vielleicht ungewollt in einem Namespace?
MrSm!th is offline  
Thanks
1 User
Old 04/11/2012, 01:58   #5
 
elite*gold: 0
Join Date: Feb 2012
Posts: 7
Received Thanks: 0
Quote:
Originally Posted by MrSm!th View Post
Liegt Object vielleicht ungewollt in einem Namespace?
Nein, die Klasse ist in keinem Namespace
ColdFreezer is offline  
Old 04/11/2012, 02:11   #6
 
elite*gold: 5
Join Date: Sep 2006
Posts: 385
Received Thanks: 218
{ gehört in eine eigene Zeile. Tu es und es wird funktionieren!

Was ich spontan versuchen würde:
Schauen, ob sf::Sprite überhaupt bekannt ist
:: vor Object schreiben.
Object in ein namespace packen und es dann darüber ansprechen.
Schauen, ob sich was im Kreis inkludiert.
Nightblizard is offline  
Old 04/11/2012, 02:28   #7
 
elite*gold: 0
Join Date: Feb 2012
Posts: 7
Received Thanks: 0
Danke an alle, mein Programm funktioniert jetzt fehlerfrei

Anscheinend hat sich irgendetwas im Kreis inkludiert @Nightblizard: Danke für den Tipp
ColdFreezer is offline  
Old 04/11/2012, 21:48   #8


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Dann hättest du aber schon ne Meldung bekommen müssen, dass die maximale Include-Tiefe erreicht ist.
MrSm!th is offline  
Old 04/12/2012, 00:04   #9
 
Tyrar's Avatar
 
elite*gold: 0
Join Date: Oct 2008
Posts: 1,637
Received Thanks: 1,119
Quote:
Originally Posted by MrSm!th View Post
Dann hättest du aber schon ne Meldung bekommen müssen, dass die maximale Include-Tiefe erreicht ist.
gcc gibt meine ich nur aus dass etwas nicht definiert ist. kann auch nen anderer compiler sein
Tyrar is offline  
Reply

Tags
c++, hilfe, problem, programmieren, vererbung




All times are GMT +1. The time now is 22:36.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.