« first day (368 days earlier)      last day (4563 days later) » 

6:00 PM
mmn, I was wondering why I add a compiler error..and it turned out that I had my class declared pubic instead of public. Ugh
 
6:11 PM
Mawning
 
Evening
 
Just moved into my new place but no internets1 :(
 
oh damn, that sucks
so how are you here?
 
Mobile internets as before
 
oh
i see
 
6:21 PM
OMFG. C/C++ managed to confuse me again!
 
sbi
@DeadMG So you have your own room/apartment again now? Cong-rats, and other rodents!
 
Always fucking pointers. DAMN POINTERS
 
Can't tether my iPhone though
And I have the suckiest mouse evor
But it could be worse- it could be a hotel
 
Is a struct a kind of object?
 
lawl
no it's a struct, when you instantiate it, you have an object I guess
 
6:23 PM
@TonyTheLion Yes exactly
 
sbi
@LewsTherin C++ manages to confuse me for 20 years now.
 
an object is an instance of something in memory, mostly like a class, but it could be struct too
 
sbi
@LewsTherin No, it's a type.
 
@sbi lol I'm never gonna get it!
@sbi I mean when you create an instance
it is an object yeah? Like a class
 
You're over-confusing things
Can you do shit with it? It's an object!
 
sbi
6:24 PM
@LewsTherin In C++, an "object" is a region of storage (preferably of a specific type), so, yeah, an instance of a struct is an object. So is an int, BTW, in C++.
 
What's so confusing about pointers?
 
@CatPlusPlus Everything
 
For pretty much any liberal definition of "shit"
 
Ok I have a class and I cast it its address to be of type (char *)&myObject and it returns me the first byte of that object in memory
I will post the damn code
 
C-style casts are ugly.
 
6:26 PM
@LewsTherin yea cause it's a char* which points to the first location in memory where the myObject is
 
class OtherClass
{

    public : int a ;
};

class newClass
{
    public : int c ;
};
class myClass:public newClass, public OtherClass
{
    public: int b ;
};
int main()
{
    myClass b;
   OtherClass *a = (OtherClass*)&b;

    char *s = (char*)&b ;

    printf("%p %p", s, &b.c) ;
}
 
@LewsTherin Meaning?
 
@LewsTherin ugly C code mixed with C++ :(
 
Undefined Behaviour
 
as expected s points to the first byte in memory...but a points to the subobject of b.. why did a not point to the beginning of b
@DeadMG where?
 
6:28 PM
I have never seen this char *s = (char*)&b; not sure when it would ever be useful
 
You can't cast to OtherClass like that
 
@TonyTheLion I saw it today, used for a struct
 
Because it is not the first base class
The first base class goes first in memory
 
@LewsTherin hmmm....
 
@DeadMG That's what I was wondering... it shouldn't have worked. but the compiler allowed it
 
6:29 PM
It's a shitty C cast- that's what you get
Never use it
 
sbi
@LewsTherin You are missing the point. C++ isn't a small toy language as Java or C#. C++ is a monster. (And when I say monster I mean a big, scary, hairy, clawed, plate-eyed, haunting, man-eating demon of the night.) And it's a cosmos. Except for a very few gurus, nobody gets it all, and even those gurus are, again and again, amazed at what others come up with. You will never "get C++" as a whole, just as physics will never "get the cosmos". But you can become Stephen Hawking, if you work hard.
14
 
@DeadMG It seemed to figure out where the address offset of OtherClass, was it just random luck.
 
It's bad and wrong
 
so is (char*)&b wrong as well?
 
If you cannot implicitly cast, nor dynamic-cast, then do not do casting shenanigans with inheritance. Ever.
 
6:31 PM
@LewsTherin it's bad, cause it's a C style cast
 
@sbi it is forever then.
 
No, char* is special case- but C cast is still wrong
 
@DeadMG Why is it wrong? Why is char* a special case
 
@LewsTherin It's not wrong if you're just trying to get a pointer to the beginning of the object, but it's better to use reinterpret_cast
 
Just don't ever go casting pointers except implicitly and dynamically, and you'll do fine
 
6:32 PM
Walla walla!
 
sbi
@LewsTherin I can assure you that you will overcome pointers, and will smile when you think back at how you struggled with them. But that doesn't mean you will ever "get C++" in the way you can get Java, or C#.
2
 
C casts are wrong because they magically change
You can make it into any of the C++ casts without warning or error
Which is very bad as they are radically different
 
in what world implementing queue using two or more stack is good?
 
sbi
Walla Walla is the largest city in and the county seat of Walla Walla County, Washington, United States. The population was 31,731 at the 2010 census. Walla Walla is in the southeastern region of Washington, approximately four hours by car from Seattle, Washington and thirteen miles from the Oregon border. Whitman College, Walla Walla Community College, and the Washington State Penitentiary are located in Walla Walla. Walla Walla University is located in nearby College Place, Washington. In addition, Baker Boyer Bank, the oldest bank in the state of Washington, was founded in Walla Wa...
 
Plus you cannot search for C casts, but you can for C++ cast keywords
 
6:34 PM
@sbi I hope so. That at least would be nice
 
sbi
@MrAnubis Yoda, is that you?
 
with C++ casts you cannot get rid of const :-)
 
@sbi arrh , was trying to speak in arabian :D , what's yoda though?
 
ah, sorry, ignore me
 
I am doing C, now so I can't use C++ in it. I used a class as an example.
 
sbi
6:35 PM
@MrAnubis Who, not what!
 
@sbi yes , who's yoda?
 
@MrAnubis you don't know who Yoda is???? Wait... wut?
 
sbi
Yoda is a fictional character in the Star Wars universe, appearing in the second and third original films, as well as all three prequel trilogy films. A renowned Jedi master, Yoda made his first on-screen appearance in Star Wars Episode V: The Empire Strikes Back where he is responsible for training Luke Skywalker in the ways of the Jedi. His final chronological appearance is Star Wars Episode VI: Return of the Jedi, when he floats away peacefully at the age of 900. He also appears extensively in the two animated Clone Wars series, as well as the Star Wars Expanded Universe of novels an...
He is using the wrong word order in his sentences, making them harder to understand.
 
aah , never saw that movie star wars :|
 
sbi
Ugh, oneboxing fail again.
@MrAnubis Which of the six you never saw?
 
6:37 PM
@MrAnubis WTF You don't know who YODA is? GTFO lol!
 
@sbi none :)
 
#include <stdio.h>
int main()
{
    int a = 10 ;

    char *s = (char*)&s ;

    printf("%d",*s) ;
}
 
I think we'll have to confiscate your geek cred
 
So what is the use of that then?
Why would anyone want to get the first byte of an object, excluding a character
 
@LewsTherin you're casting s to itself???
 
6:39 PM
@TonyTheLion good catch
 
:1706581 I guess that's endian dependent
 
(1) to show it can be done, or (2) because you need to do some kind of bit twiddling where you need to extract a single byte from an int
 
lol
 
I'm leaning towards (1)
 
#include <stdio.h>
int main()
{
    int a = 10 ;

    char *s = (char*)&a ;

    printf("%d",*s) ;
}
 
6:40 PM
that's usually why people do evil cast abuse
 
@jalf why'd anyone want to do that? extract the first byte
 
@LewsTherin that is serious offense , you should go to jail for writing such a code lol
 
@LewsTherin You? If this is your code then no clue
I've never written code and then asked what it was for.
 
sbi
@LewsTherin Over a few beers in a pub, I asked Erwin Unruh (who is generally considered to be the first to ever write a template meta-program) how it happened that he came up with this. He told me. And then I asked him how the others reacted when he showed it to them. So he showed me how Bjarne Stroustrup reacted - by hiding his eyes behind his hand. My point: Nobody, not even C++' creator, had thought TMP would be possible until they actually run into it, hurting their shins badly.
4
And I'm sure, with all the new features of C++11, the language has more surprises in store for us.
 
I didn't realize that was even possible
 
6:42 PM
@jalf anyone* not I
@jalf what?
 
never mind :)
 
@sbi so I shouldn't feel too depressed?
 
sbi
@MrAnubis Too bad, so you don't even know how we all now picture you:
 
well, you usually don't want to get the first byte of an int, which is why I said the most likely explanation was "to show it ca nbe done"
 
Here's a question
 
6:43 PM
a question
 
if you do want to get the first byte of an int, then it might be because you're fiddling with some file format or network protocol where you have to split an int up into it constituent bytes
 
@sbi that guy look very intelligent though :D
 
sbi
@LewsTherin If you like learning, there is no need to be depressed over C++, since it can provide you with things to learn for the rest of your career.
 
How can you tell the difference between a UTF32 BOM (0xFFEF0000) and a UTF16 BOM (0xFFEF) followed by 0 (0x0000)
 
sbi
@MrAnubis That he is.
 
6:45 PM
@jalf How do I tell if my machine is big endian or little endian. It prints 10 correctly and I know why because it an int from 0-255 is basically a byte. But shouldn't the it be like 0000..garbage..1010?
 
@DeadMG you.. can't? If you don't know whether your input is utf16 or utf32, I think you've already lost
 
sbi
@DeadMG That's easy: one is stored in one 32bit characters, the other in two 16bit characters. (And, no, this is not only a joke. There's some truth behind it.)
 
If it printed correctly is my machine little endian then?
@sbi thanks for the encouragement
 
Uh, the idea was that I should be able to read UTF32 from a file, even if that file was opened in ASCII mode
Isn't the point of BOMs to tell you what UTF is in a file?
 
sbi
@DeadMG You are able to do that. You will just have to know that it is UTF32.
 
6:47 PM
@DeadMG ASCII mode usually just means that newlines will be converted to whatever is native on the platform
the purpose of the BOM (byte order mark) is just to tell you the byte order
 
sbi
@DeadMG I think it tells you about byte order. hence "byte order mark".
 
so you can use it to distinguish between LE and BE UTF16
but if you don't know if it's UTF16 at all, then you're just fucked :)
 
So given a random file, I can't know what encoding it's in
 
@DeadMG nope
how would you? It's a sequence of 0's and 1's
 
@sbi you wishing to donate your mind? i need it :D
 
6:49 PM
By giving it magic starting values that tell you?
 
sbi
@DeadMG You don't even know whether it's text, and if so, what format. For all you know, it could be text in the portable document format.
 
magic starting values only work if all the potential encodings agree on them. And they don't. All the pre-unicode encodings didn't have a magic starting value, ASCII didn't have one, so the unicode encodings didn't add one either
besides, what happens if you concatenate files? Or append data to an empty file? :)
 
Same as a BOM has now
 
you end up with no header, or multiple headers in the middle of the file
@DeadMG yep
so yeah, plain text is just text, and you have to know in advance what encoding it uses
otherwise, your application can define a convention that, say, the first 4 bytes indicate the encoding of the rest of the file
 
sbi
@MrAnubis My mind is old and tired, and went through too much trouble recently to currently be worth a lot. Oh, and I forgot that it was very weird to begin with. I am sure that you would return it within minutes, making an amusingly disgusted face. :)
 
6:51 PM
The only difference is that if the UTF32 BOM was distinct from well-formed UTF16, you could at least infer 32, 16, or 8
 
@sbi lol
 
But I guess I'll just have to ask the user what encoding it's in
 
@DeadMG the BOM is optional though ;)
when text is involved, assume that you're screwed. Doubly so if you're supposed to manipulate it in C++
 
@sbi lucky me , at-least you agreed :) , i will be called sbi-meta-junior ?
 
sbi
@MrAnubis You mean I agreed trading? Why do you think I wrote you would return it (and not you will)?
 
6:56 PM
@jalf or anyone if I get the first byte of an int printed the int correctly. Does that mean my machine is little endian?
 
@sbi yes trading , i will return ofcourse
 
I guess so. I can never remember which one is little endian. I just look it up when I need it. ;)
but yeah, sounds right
 
LSB first.
 
sbi
@MrAnubis What is it with you? Can't you read?
 
what is LSB
 
6:58 PM
@jalf Little Endian = Least Significant Bit
that's how I remember it
 
Lurkingy Silent Beast.
 
@CatPlusPlus lol
 
@sbi that second part was hard to understand :(
 
@TonyTheLion good one
 
6:59 PM
@TonyTheLion but what about the least significant bit? ;)
 
Although the lsb depends on the machines though
 

« first day (368 days earlier)      last day (4563 days later) »