C++ - Problem mit Weglassen parameterlosem Konstruktor
Verfasst: 6. April 2016 11:30
Ich poste jetzt hier mal die relevanten Methoden:
Ich habe zwei Klassen: fileclass_ui erbt von fileclass_xml
wenn ich den nicht mehr benötigten Konstruktor "fileclass_xml()" (siehe "Problemstelle") auskommentiere dann bekomme ich folgende Fehlermeldung:
cpp_xml.cpp: In constructor ‘fileclass_ui::fileclass_ui(std::string)’:
cpp_xml.cpp:186:56: error: no matching function for call to ‘fileclass_xml::fileclass_xml()’
fileclass_ui::fileclass_ui(string para_dateiname_string)
^
cpp_xml.cpp:186:56: note: candidates are:
cpp_xml.cpp:52:1: note: fileclass_xml::fileclass_xml(std::string)
fileclass_xml::fileclass_xml(string para_dateiname_string)
^
cpp_xml.cpp:52:1: note: candidate expects 1 argument, 0 provided
cpp_xml.cpp:19:7: note: fileclass_xml::fileclass_xml(const fileclass_xml&)
class fileclass_xml
^
cpp_xml.cpp:19:7: note: candidate expects 1 argument, 0 provided
mv: der Aufruf von stat für „a.out“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
---------------------------------------------------------------------------------------
class fileclass_xml
{
protected:
int i;
int n;
fstream datei;
string dateiname_string;
public:
//protected: geht nicht
//fileclass_xml() { debug_writeln("HIER IST Konstruktor fileclass_xml::fileclass_xml() ohne Parameter"); } //Problemstelle
fileclass_xml(string para_dateiname_string);
~fileclass_xml();
void init();
void write_header();
void write_bottom();
void write_token(string token_name, string wert);
void writerec(string widget_class, string widget_name);
void write_all_recs();
};
---------------------------------------------------------------------------------------
//ui
class fileclass_ui : public fileclass_xml
{
protected:
int max_n;
public:
fileclass_ui(string para_dateiname_string);
~fileclass_ui();
fstream datei;
string dateiname_string;
int x, y, width, height; //werden momentan nicht alle benutzt
string x_string, y_string, width_string, height_string;
string feldwert[256];
void init();
void write_header();
void write_bottom();
void write_fields();
void write_widget_class(string widget_class, string widget_name);
void write_property_string();
void writerec(string widget_class, string widget_name);
void write_all_recs();
};
---------------------------------------------------------------------------------------
Auschnitt von fileclass:ui:
//----- KONSTRUKTOR ---------------------------------------
//kui
fileclass_ui::fileclass_ui(string para_dateiname_string) //Zeile 186
{
dateiname_string = para_dateiname_string;
cout << "Hier ist KONSTRUKTOR fileclass_ui::~fileclass_ui() dateiname_string = " << dateiname_string << endl; //debug
//dateiname_string = "datei.xml";
datei.open(dateiname_string.c_str(), ios::in | ios::out | ios::trunc);
//datei.open(dateiname_string.c_str() );
if (!datei)
{
cout << "Datei nicht verfügbar" << endl;
}
init();
} //fileclass_ui::fileclass_ui para
void fileclass_ui::write_all_recs()
{
cout << "fileclass_xml::write_all_recs() dateiname_string = " << dateiname_string << endl; //debug
write_header();
x_string="400"; width_string="200"; height_string="25";
y=50;
//write_fields(); //d1 Hier Aufruf write_fields
write_bottom(); //d2
}
/*********************************************************************************************************************************************/
/*********************************************************************************************************************************************/
/*********************************************************************************************************************************************/
int main()
{
//fileclass_xml wr("datei_fileclass_xml.xml");
fileclass_ui wr("datei.xml");
wr.write_all_recs();
}
Ich habe zwei Klassen: fileclass_ui erbt von fileclass_xml
wenn ich den nicht mehr benötigten Konstruktor "fileclass_xml()" (siehe "Problemstelle") auskommentiere dann bekomme ich folgende Fehlermeldung:
cpp_xml.cpp: In constructor ‘fileclass_ui::fileclass_ui(std::string)’:
cpp_xml.cpp:186:56: error: no matching function for call to ‘fileclass_xml::fileclass_xml()’
fileclass_ui::fileclass_ui(string para_dateiname_string)
^
cpp_xml.cpp:186:56: note: candidates are:
cpp_xml.cpp:52:1: note: fileclass_xml::fileclass_xml(std::string)
fileclass_xml::fileclass_xml(string para_dateiname_string)
^
cpp_xml.cpp:52:1: note: candidate expects 1 argument, 0 provided
cpp_xml.cpp:19:7: note: fileclass_xml::fileclass_xml(const fileclass_xml&)
class fileclass_xml
^
cpp_xml.cpp:19:7: note: candidate expects 1 argument, 0 provided
mv: der Aufruf von stat für „a.out“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
---------------------------------------------------------------------------------------
class fileclass_xml
{
protected:
int i;
int n;
fstream datei;
string dateiname_string;
public:
//protected: geht nicht
//fileclass_xml() { debug_writeln("HIER IST Konstruktor fileclass_xml::fileclass_xml() ohne Parameter"); } //Problemstelle
fileclass_xml(string para_dateiname_string);
~fileclass_xml();
void init();
void write_header();
void write_bottom();
void write_token(string token_name, string wert);
void writerec(string widget_class, string widget_name);
void write_all_recs();
};
---------------------------------------------------------------------------------------
//ui
class fileclass_ui : public fileclass_xml
{
protected:
int max_n;
public:
fileclass_ui(string para_dateiname_string);
~fileclass_ui();
fstream datei;
string dateiname_string;
int x, y, width, height; //werden momentan nicht alle benutzt
string x_string, y_string, width_string, height_string;
string feldwert[256];
void init();
void write_header();
void write_bottom();
void write_fields();
void write_widget_class(string widget_class, string widget_name);
void write_property_string();
void writerec(string widget_class, string widget_name);
void write_all_recs();
};
---------------------------------------------------------------------------------------
Auschnitt von fileclass:ui:
//----- KONSTRUKTOR ---------------------------------------
//kui
fileclass_ui::fileclass_ui(string para_dateiname_string) //Zeile 186
{
dateiname_string = para_dateiname_string;
cout << "Hier ist KONSTRUKTOR fileclass_ui::~fileclass_ui() dateiname_string = " << dateiname_string << endl; //debug
//dateiname_string = "datei.xml";
datei.open(dateiname_string.c_str(), ios::in | ios::out | ios::trunc);
//datei.open(dateiname_string.c_str() );
if (!datei)
{
cout << "Datei nicht verfügbar" << endl;
}
init();
} //fileclass_ui::fileclass_ui para
void fileclass_ui::write_all_recs()
{
cout << "fileclass_xml::write_all_recs() dateiname_string = " << dateiname_string << endl; //debug
write_header();
x_string="400"; width_string="200"; height_string="25";
y=50;
//write_fields(); //d1 Hier Aufruf write_fields
write_bottom(); //d2
}
/*********************************************************************************************************************************************/
/*********************************************************************************************************************************************/
/*********************************************************************************************************************************************/
int main()
{
//fileclass_xml wr("datei_fileclass_xml.xml");
fileclass_ui wr("datei.xml");
wr.write_all_recs();
}