Hello and thanks in advance for helping, I've the problem that I don't see any output on my eclipse console (on linux ubuntu 12.04). I have this little C++ program:
Addressverwaltung.cpp:
#include <iostream>
#include "Adresse.h"
using namespace std;
int main() {
cout << "asdf";
Adresse lAdresse1("Max", "Tester", "Strasse 21", 6423, "lol", "[email protected]");
lAdresse1.printAdresse();
lAdresse1.setName("Testing");
lAdresse1.printAdresse();
return 0;
}
Adresse.h:
#ifndef Adresse_h
#define Adresse_h
#include <iostream>
#include <string>
class Adresse{
public:
Adresse(std::string pVorname, std::string pName);
Adresse(std::string pVorname, std::string pName, std::string pStrasse, int pPlz, std::string pOrt, std::string pEmail);
void printAdresse();
void setVorname(std::string pVorname);
void setName(std::string pName);
std::string getName();
private:
std::string mVorname;
std::string mName;
std::string mStrasse;
int mPlz;
std::string mOrt;
std::string mEmail;
};
#endif
Adresse.cpp:
#include "Adresse.h"
Adresse::Adresse(std::string pVorname, std::string pName){
mVorname = pVorname;
mName = pName;
}
Adresse::Adresse(std::string pVorname, std::string pName, std::string pStrasse, int pPlz, std::string pOrt, std::string pEmail){
mVorname = pVorname;
mName = pName;
mStrasse = pStrasse;
mPlz = pPlz;
mOrt = pOrt;
mEmail = pEmail;
}
void Adresse::printAdresse(){
std::cout << "ADRESSE:";
std::cout << mVorname + mName;
std::cout << "STRASSE: " + mStrasse;
std::cout << "PLZ: " + mPlz;
std::cout << "EMAIL: " + mEmail;
}
void Adresse::setVorname(std::string pVorname){
mVorname = pVorname;
}
void Adresse::setName(std::string pName){
mName = pName;
}
std::string Adresse::getName(){
return mName;
}
Whenever I click "run" I see the message "make all make: Nothing to be done for `all'." for about 4 seconds, afterwards the console is empty. I tried cleaning and rebuilding the project but that doesn't help. Does anyone know how to fix this?
Put a cout.flush() before the return in main() function. That should help:
int main() {
cout << "asdf";
Adresse lAdresse1("Max", "Tester", "Strasse 21", 6423, "lol", "[email protected]");
lAdresse1.printAdresse();
lAdresse1.setName("Testing");
lAdresse1.printAdresse();
cout.flush(); // <<<<<<<<<<<<<<<<<<<<<<<<
return 0;
}