Re: Assign pointers of different objects to the same pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I have already given you the correct answer.  What did you not like
> about it?
>
> Andrew.

Nothing against your answer that's all correct and well.
What I don't like is the protection mechanism of c++ that causes that problem 
and the main disadvantage, sorry, the only thing making problems in c++.
I first wanted to be sure that there is no way - and now I know that there is 
no way to solve this inside c++.

But it would be nice to see gcc making this break of ISO-C++, that programmers 
can use pointers in that way.

Maybe you don't get me (that problem) right:

Pointers are on a system IA32 32 bit pointers on IA64 64 bit pointers that are 
of type int32 or int64 so all pointers have the same type on the same system.
(That's pointers get handled in other languages, without a standard for 
objective oriented programming)
But a pointer can point to whatever you want and it doesn't make sense to call 
(execute) a long int variable when you wanted to initialise your new widget - 
over such a pointer. So c++ has type checking of pointers to do better error 
massages and protection (C deffines here ++, objective oriented programming).
If you now have a stack holding only pointers to functions than you can call 
this pointers over a number added to that stack pointer (class) and any 
function can get executed like in QT. But if you want to change a class in 
one of that positions that don't have the same type than c++ can do type 
checking and doesn't allow that. But if that types won't be the same it 
wouldn't matter, than an other class is initialised or member is executed. So 
ISO-C++ could allow to overwrite these style of pointers. The only thing can 
happen is if a not void function get called, on a programmers mistake, 
instead of another function holding variables too, than c++ can't say what 
error occurred, so only void functions and initialisations can be allowed, 
that the programme won't crash with an undefined error.
If all classes you use are your own than you don't need that, but if you don't 
know the instances of QT than this would help a lot and save a lot of time of 
course (maybe 2 days in my case).

             Sebastian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux