#include<iostream>
using namespace std;
class Nokta{
private:
int x,y;
public:
Nokta();
Nokta(int, int);
int getX();
int getY();
void setX(int);
void setY(int);
};
Nokta::Nokta(){
cout << "parametresiz kurucu cagrildi\n";
}
Nokta::Nokta(int x, int y=0){
this->x = x;
this->y = y;
cout << "parametreli kurucu cagrildi\n";
}
int Nokta::getX(){
return x;
}
int Nokta::getY(){
return y;
}
void Nokta::setX(int _x){
x=_x;
}
void Nokta::setY(int _y){
if(_y > 5)
y=_y;
else
y = 2;
}
int main(){
Nokta *ptr;
cout << ptr << " " << &ptr << " "<< ptr->getX() << endl;
return 0;
}
Nokta* ptr; A constructor function is not called when I type it, but I can print one of its variables to the screen. ptr->getX() works. I guess this value is randomly assigned, but how is it done in the background before an object is created?
Output
0x401b6b 0x61ff0c 1528349827