gollum1990
Neues Mitglied
Hallo liebes Forum,
Ich habe mir mal ein kleines Programm geschrieben, nur so zum Test. Aber bei der Programmausführung schmiert das Program ab.
Der Compiler kompiliert fehlerfrei(jedenfalls zeigt der keine Fehler an).
Im Debug Modus bekomme ich gesagt:
Error Access (fault) ...
Programm Code:
[main.cpp]
[namespaces_1.h]
[namespaces_1.cpp]
Habt ihr vielleicht Lösungvorschläge?
MFG gollum1990
Ich habe mir mal ein kleines Programm geschrieben, nur so zum Test. Aber bei der Programmausführung schmiert das Program ab.
Der Compiler kompiliert fehlerfrei(jedenfalls zeigt der keine Fehler an).
Im Debug Modus bekomme ich gesagt:
Error Access (fault) ...
Programm Code:
[main.cpp]
Code:
#include <cstdlib>
#include <iostream>
#include "namespaces_1.h"
using namespace std;
using namespace no1;
int main(int argc, char *argv[])
{
IO *new_io;
Ausgeber *new_ausgeber;
new_io->input = 50;
new_io->output = 10;
new_io->addInput(100);
new_io->addOutput(500);
new_ausgeber->getInput();
new_ausgeber->getOutput();
system("PAUSE");
return EXIT_SUCCESS;
}
[namespaces_1.h]
Code:
#ifndef no1_h
#define no1_h
namespace no1
{
class IO
{
public:
int input;
int output;
void addInput(int new_input);
void addOutput(int new_output);
};
class Ausgeber : public IO
{
public:
void getInput();
void getOutput();
};
}
#endif
[namespaces_1.cpp]
Code:
#include <iostream>
#include <cstdlib>
#include "namespaces_1.h"
using namespace std;
using namespace no1;
void IO::addInput(int new_input)
{
IO::input += new_input;
}
void IO::addOutput(int new_output)
{
IO::output += new_output;
}
void Ausgeber::getInput()
{
cout << input << "\n" << endl;
}
void Ausgeber::getOutput()
{
cout << output << "\n" << endl;
}
Habt ihr vielleicht Lösungvorschläge?
MFG gollum1990