C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vererbungs - Prob

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Christian Eikermann
Guest





PostPosted: Mon Mar 20, 2006 6:12 pm    Post subject: Vererbungs - Prob Reply with quote



Hallo NG,

Ich versuche mir gerade ein kleines Proggie zu schreiben, welches einen Text
auf phpBB und Easyhtml formatiert. Ich wollte mit gleich von vorneherein
Klassen anlegen, die ich wiederverwerten kann. nur compliliert der compiler
nicht, der meckert immer wegen des Gültigkeitsbereichs. Hir das Proggi:


#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;

class textfile {
private:
public:
ofstream ofs;
ifstream ifs;
string outfile;
string infile;
inline bool open_outfile() {
ofs.open(outfile.c_str(),ios::out|ios::trunc);
if(!ofs.good())
{ return false;
} else return true;
}
inline bool open_infile() {
ifs.open(infile.c_str(),ios::in);
if(!ifs.good())
{ return false;
} else return true;
}
inline textfile() {

}
inline ~textfile() {
ifs.close();
ofs.close();
}
};

class encode_ua_2_phpbb : textfile {
private:
public:
inline encode_ua_2_phpbb() : textfile() {}
inline ~encode_ua_2_phpbb() {}
};

class uaform : public encode_ua_2_phpbb {
private:
public:
inline uaform() : encode_ua_2_phpbb() {
}
inline ~uaform() {
}
};

int main(int argc, char *argv[])
{
uaform run;
run.infile="uastat.txt";
run.outfile="uastat.out";
if(!(run.open_infile()&&run.open_outfile())) cerr <<"Fehler!"<<endl;
run.ofs << "test - vererbt, alles ok";
return EXIT_SUCCESS;
}

Wäre nett, wenn mir da einer helfen könnte.
--
MfG,

Christian Eikermann

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Rolf Magnus
Guest





PostPosted: Tue Mar 21, 2006 1:06 am    Post subject: Re: Vererbungs - Prob Reply with quote



Christian Eikermann wrote:

Quote:
Hallo NG,

Ich versuche mir gerade ein kleines Proggie zu schreiben, welches einen
Text auf phpBB und Easyhtml formatiert. Ich wollte mit gleich von
vorneherein Klassen anlegen, die ich wiederverwerten kann. nur compliliert
der compiler nicht, der meckert immer wegen des Gültigkeitsbereichs.

Was heißt das? In welcher Zeile meckert er? Über den Gültigkeitsbereich von
was? Wie lautet die genaue Fehlermeldung?

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
name
Guest





PostPosted: Tue Mar 21, 2006 2:06 pm    Post subject: Re: Vererbungs - Prob Reply with quote



Am Mon, 20 Mar 2006 14:12:05 +0100 schrieb Christian Eikermann:

Quote:
Hallo NG,

Ich versuche mir gerade ein kleines Proggie zu schreiben, welches einen Text
auf phpBB und Easyhtml formatiert. Ich wollte mit gleich von vorneherein
Klassen anlegen, die ich wiederverwerten kann. nur compliliert der compiler
nicht, der meckert immer wegen des Gültigkeitsbereichs. Hir das Proggi:


#include <iostream
#include <string
#include <fstream
#include <cstdlib
using namespace std;

class textfile {
private:
public:
ofstream ofs;
ifstream ifs;
string outfile;
string infile;
inline bool open_outfile() {
ofs.open(outfile.c_str(),ios::out|ios::trunc);
if(!ofs.good())
{ return false;
} else return true;
}
inline bool open_infile() {
ifs.open(infile.c_str(),ios::in);
if(!ifs.good())
{ return false;
} else return true;
}
inline textfile() {

}
inline ~textfile() {
ifs.close();
ofs.close();
}
};

class encode_ua_2_phpbb : textfile {
private:
public:
inline encode_ua_2_phpbb() : textfile() {}
inline ~encode_ua_2_phpbb() {}
};

class uaform : public encode_ua_2_phpbb {
private:
public:
inline uaform() : encode_ua_2_phpbb() {
}
inline ~uaform() {
}
};

int main(int argc, char *argv[])
{
uaform run;
run.infile="uastat.txt";
run.outfile="uastat.out";
if(!(run.open_infile()&&run.open_outfile())) cerr <<"Fehler!"<<endl;
run.ofs << "test - vererbt, alles ok";
return EXIT_SUCCESS;
}

Wäre nett, wenn mir da einer helfen könnte.
--
MfG,

Christian Eikermann



Der Fehler liegt in der falschen Vererbung.
Statt
class encode_ua_2_phpbb : textfile {

korrekt ableiten:

class encode_ua_2_phpbb : public textfile {

dann läuft es auch.

Viele Grüsse

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.