illegal pointer to class object hist1 0x0 993 (tmpfile)

0
167

If you know me, you know that I’m a sucker for those kinds of things. I hate when people write “illegal pointer to class object hist1 0x” in their code because I’ll laugh and call them “dumb”. Of course, I still love it when people do it, as in this case.

In the case of this case, the illegal pointer to class object hist1 0x 993 (tmpfile) is actually a pointer to a class object.

This is a pointer to an object of an object that was created by the user. This object represents a class that was created by the user. There is nothing special about this particular object, so the name will be whatever the object’s name in the source code is.

Once again, this is a pointer to a class object. This is the same as the example above of a class with no constructor. This is an illegal pointer since the compiler can’t tell the difference between a class object and a pointer to a class object.

This isn’t a pointer to a class, but to a class that was created by the user. So, again, you can’t do this, but you can have a pointer to a class.

I was wondering if this is a pointer to a class or a pointer to an array or a pointer to an instance of a class? Since the compiler doesnt see the difference and just knows that its a pointer to a class, then it cant see any problems and it cant complain. Now to be clear, I am not trying to be confusing, I just wanted to have the example point out that it is possible to do something like this.

I guess when you create an object the compiler doesn’t know that you want to get a pointer to it. I don’t know if the compiler would even allow you to, but this is how you would do it anyway.

You can, and should, do this, but it makes little sense to do it. This sort of coding is a big no-no.

Another way to do this is to do a cast to class object which will allow you to look at the class object itself. It’s just a bit more confusing and you have to be careful because you don’t want to make some of your code a bit more complicated than it needs to be because the compiler does not know what class it is, which is a deal-breaker for most people.

LEAVE A REPLY

Please enter your comment!
Please enter your name here