Dzięki . Tutaj pomogło, ale pojawił się podobny problem dalej... nie wiem gdzie jest mój problem w rozumowaniu.
mikro.h
#ifndef MIKRO_H
#define MIKRO_H
#include <iostream>
#include <string>
using namespace std;
class Micro{
private:
string name;
int power;
public:
static int amount;
Micro();
~Micro();
void init();
void addName();
void grillOption();
void createDoor();
};
class Door{
private:
Door(Door& d1);
bool position;
public:
Door();
~Door();
void choosePosition();
};
class Grill{
private:
int* Heat;
public:
Grill();
~Grill();
void initGrill(const int powerX);
//Grill& operator+(const int* addHeat);
// Grill& operator-(const int* minusHeat);
};
#endif
mikro.cc:
#include <iostream>
#include <string>
#include "mikro.h"
using namespace std;
int Micro::amount=0;
//KONSTRUKTORY - MICRO
;
Micro::Micro()
{
#ifdef TESTPR1
cout << "konstruktor Micro dziala" << endl;
#endif
name = "";
power = 100;
amount++;
}
Micro::~Micro()
{
#ifdef TESTPR1
cout << "destruktor Micro dziala" << endl;
#endif
name = "";
power = 0;
amount--;
}
//FUNKJE - MICRO
void Micro::init()
{
this->addName();
this->grillOption();
this->createDoor();
}
void Micro::addName()
{
cout<<"Podaj nazwe modelu mikrofalowki"<< endl;
cin>> name;
}
void Micro::grillOption()
{
string t;
cout << "Jesli chcesz skorzystac z grilla wpisz '1'" << endl;
cin >> t;
if(t=="1")
{
int showPower;
Grill *nGrill;
nGrill=new Grill; cout << "doopa";
nGrill->initGrill(showPower); cout << "doopa";
}cout << "doopa";
}
void Micro::createDoor()
{
Door* nDoor;
nDoor=new Door;cout << "jestem";
nDoor->choosePosition(); cout << "jestem123";
}
//KONSTRUKTORY - GRILL
Grill::Grill()
{
#ifdef TESTPR1
cout << "konstruktor Grill dziala" << endl;
#endif
Heat=0;
}
/*
Grill& Grill::operator+(const int* addHeat)
{
*Heat = *Heat + 150;
}
Grill& Grill::operator-(const int* minusHeat)
{
Heat = Heat - 150;
}
*/
Grill::~Grill()
{
#ifdef TESTPR1
cout << "destruktor Grill dziala" << endl;
#endif
Heat=0;
}
void Grill::initGrill(const int powerX)
{
this->Heat = powerX + 200; cout << "dsajsad"<<endl;
}
//wsk=&n;
//*wsk=0;
//DOOR
Door::Door()
{
#ifdef TESTPR1
cout << "konstruktor Door dziala" << endl;
#endif
position=false;
}
Door::~Door()
{
#ifdef TESTPR1
cout << "destruktor Door dziala" << endl;
#endif
position=false;
}
void Door::choosePosition()
{
string k = "";
while(k!="0")
{
cout << "Chcesz zamknac drzwi?" << endl;
cin >> k;
//jesli nie zamknie, badz wpisze cos innego, program czeka, a¿ u¿ytkownik siê zgodzi :-)
}
position=true;
}
main.cc
#include <iostream>
#include "mikro.h"
using namespace std;
int main()
{
Micro Example1;
Example1.init();
}