I am back again with a new query...preparing for technical interview questions
---------------------------------
Without using sizeof operator,can we find sizeof datatype.
SpS 34 Posting Pro
Recommended Answers
Jump to PostMy first reaction would be to say that sizeof is part of the language and go down that path...
But one technique that might be used is to declare an array of a least two of the objects, declare two pointers to char; then cast & assign the address …
Jump to Postnot guaranteed to work for all types. Some it will, some it wont. Theres no standard way of doing this. Its no coincidence that sizeof is a keyword.
Could you elaborate, please?
Jump to PostIf you use an actual array, &array[0] is just a weird way of saying array.
#include <iostream> class hiddenaddr { public: void* operator &()const { return NULL;} }; class noaddrop { private: void* operator &()const; }; int main() { hiddenaddr x[1]; std::cout << ((char *)(x + 1)) …
All 11 Replies
Dave Sinkula 2,398 long time no c Team Colleague
SpS 34 Posting Pro
Stoned_coder 6 Junior Poster
Dave Sinkula 2,398 long time no c Team Colleague
Stoned_coder 6 Junior Poster
Stoned_coder 6 Junior Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Stoned_coder 6 Junior Poster
Rashakil Fol 978 Super Senior Demiposter Team Colleague
Stoned_coder 6 Junior Poster
Stoned_coder 6 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.