I've always wondered how the
Code:
sizeof()
operator works. So, I googled how it works but everything that I saw in the first two pages was basically useless to what I mean by my question. All websites explain a tutorial on "what sizeof() does" and "how to use sizeof()" but none of them came close enough to explaining how it works.

Does it already have the values of int , float, etc. saved for use or does it calculate it each time when used?
How does it calculate the size of a string? Does it count the number of places/bytes till it encounters a 0 character? If so, wouldn't it take up some processing time if the string is quite long (therefore, leading me to conclude that it doesn't count the number of bytes for each time it is associated with a string)?

Let's say I wanted to make a function does everything what sizeof could do. Could someone tell me what we'd be looking at and how something like this should be approached?

I am a little bit inexperienced when it comes to programming due to my lack of interest in learning C++ at school for the first few months but as time passed by, dedicating myself to learning C++ and programming in general is the only thing I want to do at this point of time between having to study other subjects (Phy, Chem, Math etc though I do love Math) and learning programming. I intend to write my own program features like string manipulation, vectors, etc by thr end of this year (I think I know how to approach it but I'll ever know unless I start trying and if, or when, I fail, it would be a good learning experience popping back on here and getting my doubts cleared).