| | |
Understanding binary data and algorithms--
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I'm enjoying the book Effective C++. It has highlighted things that I've looked over, never heard of, or never even though of before! However, even with this book my understanding of C++ still doesn't seem to be solid.
For some time now I've been curious about how binary data is handled as well as developing efficient algorithms to improve performance. My curiosity grew after seeing a lot of posts here that strictly deal with data problems (conversions, casts, copying data, serialization and file I/O, binary algorithms, etc).
From what I understand, at some point or another, an object in C++ holds data based on the built-in types of C++ (and if it doesn't, I'd assume for that object to be a "tool" object, like pow or other math funcctions I suppose). What I want to understand is how to have better control of data and how it is represented in a class, structure, union or namespace. Basically a recommendation for a book that really goes in depth on how data is represented in all possible data containers.
For example, how is data (at the binary level) sorted in a struct or a class? In a union it's fairly straightforward (the amount of memory that's used in a union is shared across its members). For classes and structs I'd assume for it to be conditional (what separates the binary representation of the data, or is it simply "summed up?"). Additionally how does a namespace resolve data - is it different or the same as classes and structs?
Furthermore, is there a binary representation of the access level of the data, signature of the data, and parameters of the data? During serialization and file I/O, how is the information read and remembered?
So far, C++ has improved my understanding and ability to learn the concepts of programming in general. I am fairly confident that a book that covers a lot of these details in depth will improve my knowledge and help me progress without wondering how a lot of the good programmers here are just "so good." =)
If anyone has any recommendations of a book that has this information, please let me know!
Thanks,
-Alex
For some time now I've been curious about how binary data is handled as well as developing efficient algorithms to improve performance. My curiosity grew after seeing a lot of posts here that strictly deal with data problems (conversions, casts, copying data, serialization and file I/O, binary algorithms, etc).
From what I understand, at some point or another, an object in C++ holds data based on the built-in types of C++ (and if it doesn't, I'd assume for that object to be a "tool" object, like pow or other math funcctions I suppose). What I want to understand is how to have better control of data and how it is represented in a class, structure, union or namespace. Basically a recommendation for a book that really goes in depth on how data is represented in all possible data containers.
For example, how is data (at the binary level) sorted in a struct or a class? In a union it's fairly straightforward (the amount of memory that's used in a union is shared across its members). For classes and structs I'd assume for it to be conditional (what separates the binary representation of the data, or is it simply "summed up?"). Additionally how does a namespace resolve data - is it different or the same as classes and structs?
Furthermore, is there a binary representation of the access level of the data, signature of the data, and parameters of the data? During serialization and file I/O, how is the information read and remembered?
So far, C++ has improved my understanding and ability to learn the concepts of programming in general. I am fairly confident that a book that covers a lot of these details in depth will improve my knowledge and help me progress without wondering how a lot of the good programmers here are just "so good." =)
If anyone has any recommendations of a book that has this information, please let me know!
Thanks,
-Alex
Last edited by Alex Edwards; Aug 18th, 2008 at 12:59 pm.
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
Stan Lippman's Inside the C++ Object Model
http://www.amazon.com/Inside-Object-.../dp/0201834545
http://www.amazon.com/Inside-Object-.../dp/0201834545
Last edited by vijayan121; Aug 18th, 2008 at 1:04 pm.
•
•
•
•
Originally Posted by Alex Edwards
What I want to understand is how to have better control of data and how it is represented in a class, structure, union or namespace. Basically a recommendation for a book that really goes in depth on how data is represented in all possible data containers.
Last edited by Radical Edward; Aug 18th, 2008 at 1:05 pm.
If at first you don't succeed, keep on sucking until you do succeed.
•
•
Join Date: Mar 2008
Posts: 1,400
Reputation:
Solved Threads: 113
Data stored in classes / structures is not seperated by anything, it can almost be though of as a complex array that can hold different data types. That is how you can use reinterpret_cast so that another structure, or even just an array can get the data from the structure. Look at this example:
It seems to me like your interested in alot of the low level details, So I suppose I could recommend this book (even though I haven't got yet, but I plan on getting). It will definitely give you some knowledge about how this stuff works, as it even teaches you how to write your own assembler. It also has very good ratings. But most of this will be based on assembly language so make sure you know a bit before buying this book
Hope this helps.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; struct A { char a, b, c, d, e, f; }; int main() { A a; a.a = 'H'; a.b = 'e'; a.c = 'l'; a.d = 'l'; a.e = 'o'; a.f = 0; char *str = reinterpret_cast<char*>( &a ); cout << str; cin.ignore(); return 0; }
It seems to me like your interested in alot of the low level details, So I suppose I could recommend this book (even though I haven't got yet, but I plan on getting). It will definitely give you some knowledge about how this stuff works, as it even teaches you how to write your own assembler. It also has very good ratings. But most of this will be based on assembly language so make sure you know a bit before buying this book

Hope this helps.
![]() |
Similar Threads
- exam technique? (C++)
Other Threads in the C++ Forum
- Previous Thread: About the modulo operator
- Next Thread: "Taking an address"
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






