G
Giancarlo Berenz
Hi:
Recently i write this code:
class Simple
{
private:
int value;
public:
int GiveMeARandom(void);
int GiveMeValue(void);
}
int Simple::GiveMeARandom(void)
{
return rand()%100;
}
int Simple::GiveMeValue(void)
{
return this->value;
}
....
int main()
{
Simple * Object = NULL;
printf("%d",Object->GiveMeARandom());
return 0;
}
Well, this code compile's ok and when i tried to use them... works!,
but my question is how i can access to a method of an object that not
exist in memory?. In the other hand, if you try to access to the other
method like this:
printf("%d",Object->GiveMeValue());
it crash!, and obviusly it crash because the object not exist in
memory and when you attempt to access to it variable "value" it read's
the 0x00000 direction.
But my question is about the method, the method's in C++ classes
exists without produce any object in code?. I'm thinking about and i
have a possibly explanation but what do you think about?.
Thanks
Giancarlo Berenz
Recently i write this code:
class Simple
{
private:
int value;
public:
int GiveMeARandom(void);
int GiveMeValue(void);
}
int Simple::GiveMeARandom(void)
{
return rand()%100;
}
int Simple::GiveMeValue(void)
{
return this->value;
}
....
int main()
{
Simple * Object = NULL;
printf("%d",Object->GiveMeARandom());
return 0;
}
Well, this code compile's ok and when i tried to use them... works!,
but my question is how i can access to a method of an object that not
exist in memory?. In the other hand, if you try to access to the other
method like this:
printf("%d",Object->GiveMeValue());
it crash!, and obviusly it crash because the object not exist in
memory and when you attempt to access to it variable "value" it read's
the 0x00000 direction.
But my question is about the method, the method's in C++ classes
exists without produce any object in code?. I'm thinking about and i
have a possibly explanation but what do you think about?.
Thanks
Giancarlo Berenz