c++ - How does compiler understand the pointer type? -


How does the C ++ compiler understand the indicator type? I know that the pointer is the size of the OS (32 or 64) of the word. So does it store some information about 32 (or 64) types of bits? Just because you can not have an indicator on one type and assign that point to another point with another type.

An indicator is usually just a memory address on x86 based architecture (about other architecture do not know). Compiler implement type protection with various pointers in compiling time - as it does not make any point-to-ar to specify point-to-er, for example, especially when the objects There are different shapes to point out (so you can grab random memory if you access them) You can explicitly override it and reinterpret_cast & lt; T & gt; , or static_cast & lt; T & gt; Can assign any other pointer to any pointer with other types of artists such as and dynamic_cast & lt. ; T & G; (The latter two are generally recommended due to being 'safe', but each is used for them).

So there is a memory address at the machine level, only one memory address and CPU will fulfill the duty of any access or call on it though it is dangerous because you can mix the type and about it Probably do not know. The compilation helps to avoid checking time, but usually there is no information about the actual type stored within the pointer on the runtime.

One advantage of the Iterator (indicator cover provided by STL) is that there are too many additional checks in the implementation, which can be enabled at runtime: like you check You are using the correct container, when you compare them, they are the same type of Iterator, and so on. This is one of the main reasons for using an iterator on pointers - but this is not required according to the standard, so check your implementation.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -