All pastes #282442 Raw Edit

Unnamed

public cpp v1 · immutable
#282442 ·published 2006-12-17 16:16 UTC
rendered paste body
#include <iostream>using namespace std;class Supermarkt{	protected:		char markt[100];	public:		Supermarkt(const char* m="")		{			strncpy(markt,m,100);			}		~Supermarkt(){}		const char* get_markt() const { return markt; }};class Brot : public Supermarkt{	protected:		char brot[100];		unsigned int gramm;	public:		Brot(const char* b="", unsigned int g=0, const char* m="?"):Supermarkt(m)		{			strncpy(brot, b, 100);			gramm=g;		}		~Brot(){}		void Initialisiere(const char* b="", unsigned int g=0)		{			strncpy(brot, b, 100);			gramm=g;		}		unsigned int get_gramm() const { return gramm; }		const char* get_brot() const { return brot; }};class Wurst : public Supermarkt{	protected:		char wurst[100];		unsigned int scheiben;	public:		Wurst(const char* w="", unsigned int s=0, const char* m="?"):Supermarkt(m)		{			strncpy(wurst, w, 100);			scheiben = s;		}		~Wurst(){}		void Initialisiere(const char* w="", unsigned int s=0)		{			strncpy(wurst, w, 100);			scheiben = s;		}		unsigned int get_scheiben() const { return scheiben; }		const char* get_wurst() const { return wurst; }};class Wurstbrot : public Brot, public Wurst{	public:		Wurstbrot(const char* b, unsigned int g, const char* s1,			  const char* w, unsigned int s, const char* s2):			  Brot(b,g,s1), Wurst(w,s,s2) {}		~Wurstbrot(){}		void InitAlle(const char* b, unsigned int g,			      const char* w, unsigned int s)		{			strncpy(brot, b, 100);			gramm=g;			strncpy(wurst, w, 100);			scheiben = s;		}		void get_all() const		{			cout << "-- " << Brot::get_markt() << "\t -----------\n";			cout << "|  Gramm\t\t: " << get_gramm() << '\n';			cout << "|  Brot\t\t: " << get_brot() << '\n';			cout << "-- " << Wurst::get_markt() << "\t -----------\n";			cout << "| Scheiben\t: " << get_scheiben() << '\n';			cout << "| Wurst\t\t: " << get_wurst() << '\n';		}};int main(){	Wurstbrot wbrot("Vollkornbrot", 100, "Meier", "Salami", 3, "Eberhardt");	wbrot.get_all();	return 0;}