Witam,
Piszę program obiektowy przechowujący punkty w przestrzeni trójwymiarowej.
Zawartość pliku main.cpp :
#include <iostream>
#include "ololo.h"
using namespace std;
class Punkt;
int main()
{
Punkt A("A");
cout<<"Stworzy\210em obiekt klasy Punkt!"<<endl;
return 0;
}
Pliku ololo.h :
#include <iostream>
using namespace std;
class Punkt
{
double x,y,z;
string nazwa;
public:
Punkt(string="O",double=0,double=0,double=0);
~Punkt();
};
Oraz pliku ololo.cpp :
#include <iostream>
#include "ololo.h"
using namespace std;
Punkt::Punkt(string a,double b,double c,double d)
{
if(a=="")
{
cout<<"error!"<<endl;
}
else
{nazwa=a;
x=b;
y=c;
z=d;}
}
Punkt::~Punkt()
{
cout<<"A teraz go ju\276 nie ma!";
}
Moje pytanie brzmi: dlaczego przy uruchomieniu programu otrzymuję kominikat:
Stworzyłem obiekt klasy Punkt!
A teraz go już nie ma!
Process returned 0 (0x0) execution time : 0.094 s
Press any key to continue.?
skoro nie wywoływałem destruktora w ciele funkcji main()?