Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I learned C

Name: Anonymous 2007-04-05 4:23 ID:XM7baoLH

What do I read to learn C++?

I like books with little text and lots of short example code. But anything good is fine.

Name: Anonymous 2007-04-05 4:30 ID:Heaven

sage, C is for trolls

Name: Anonymous 2007-04-05 6:53 ID:+9Hy/yKb

>>1  Stroustrup

Name: Anonymous 2007-04-05 8:19 ID:FfE1V2j0

>>1
Learn it, master1z0r1z0r it and only after learn C++

Name: Anonymous 2007-04-05 10:51 ID:pEIme/ix

If you know C why would you want to learn C++ ?
what kind of silly logic is this

Name: Anonymous 2007-04-05 11:19 ID:ZKaIPKGi

"Accelerated C++" by Koenig and Moo.  Knowing C won't help you as much as you think it will.

Name: Anonymous 2007-04-05 12:58 ID:F51LfmFx

>>6
LOL

I downloaded that book thinking knowing some C++ couldn't hurt. It might even make me a better programmer. Etc.

Then I see code like

template<class T> class Ptr { public:
    // new member to copy the object conditionally when needed 
    void make_unique() {
        if (*refptr != 1) {
            --*refptr;
            refptr = new size_t(1);
            p = p ? p->clone() : 0;
        }
    }
    
    // the rest of the class looks like Ref_handle except for its name
    Ptr(): refptr(new size_t(l)), p(0) { }
    Ptr(T* t): refptr(new size_t(l)), p(t) { }
    Ptr(const Ptr& h): refptr(h.refptr), p(h.p) { ++*refptr; }
    Ptr& operator=(const Ptr&) ;   // implemented analogously to §14.2/261
    ~Ptr();                        // implemented analogously to §14.2/262
    operator bool() const { return p; }
    T& operator*() const;,         // implemented analogously to §14.2/261
    T* operator->() const;         // implemented analogously to §14.2/261
private:
    T* p;
    size_t* refptr;
};


?????????????????

Back to Haskell it is.

Name: Anonymous 2007-04-05 14:47 ID:G61PEQ6g

p = p ? p->clone() : 0;
..
MY FUCKING EYES

Name: Anonymous 2007-04-05 15:40 ID:Heaven

[code]if (p) p = p->clone();
p = p ? p->clone() : 0;[code]
quite a space saver, lol

Name: Anonymous 2007-04-05 15:40 ID:Heaven

if (p) p = p->clone();
p = p ? p->clone() : 0;

i fail at shittags

Name: Anonymous 2007-04-05 15:43 ID:vAuMdnNJ

Brainfuck is the next logical step.

Name: Anonymous 2007-04-05 16:37 ID:BNiHm/nA

>>6

Name: Anonymous 2007-04-05 17:15 ID:+9Hy/yKb

>>7

That's easymode.  You're not allowed to be scared until you get into template metaprogramming.  Now that's frightening shit.

Name: Anonymous 2007-04-05 17:42 ID:Heaven

>>10
That's not implemented analogously to §14.2/261.

Name: Anonymous 2007-04-05 21:46 ID:mBYG1QV0

>>8
So when exactly does the trinary operator confuse anyone to the point of exclaiming, "MY FUCKING EYES"?

Name: Anonymous 2007-04-05 23:00 ID:+QersW35

>>15

Never

Name: Anonymous 2007-04-06 2:56 ID:pSBCbQpL

>>15
Never, but that whole code segment is terrible.

Name: Anonymous 2007-04-06 3:00 ID:SfYRveQQ

>>17
p = p ? p->clone() : 0;
That particular statement? What's so hard to understand about that?

Name: Anonymous 2007-04-06 3:03 ID:pSBCbQpL

>>18
Never, I meant the entire block in >>7

Name: Anonymous 2007-04-06 4:35 ID:SfYRveQQ

>>19
Ok, cool.

Also, Never.

Name: Anonymous 2007-04-06 6:23 ID:w61NsSb+

>>15 , >>18

MY FUCKING EYES FUCKING HURT BECAUSE THIS FUCKING CODE IS FUCKING TERRIBLE.
THIS CODE IS SO TERRIBLE THAT COULD ACTUALLY WIN AT THE UNDERHANDED C CONTEST.
(http://www.brainhz.com/underhanded/)


p=(p=p?p=p:0);

LOOK HOW COOL MY CODE LOOKS LIK

Name: Anonymous 2007-04-06 7:38 ID:ryKTpqqR

I really don't see what's so bad about the block of code in >>7.  The only thing I find stylistically unappealing is putting the public: right after the opening brace.

All the actual code is straightforward and pretty simplistic.  Good example code.

Name: Anonymous 2007-04-06 9:13 ID:Heaven

>>22
you are a fucking idiot, seriously GET TEH FUCK OUT OF /prog/ and go code for microsoft. kthxbai.

Name: Anonymous 2007-04-06 10:17 ID:ryKTpqqR

>>23

It's a very straightforward reference counted pointer.  It's not like the average dev ever really needs to write this sort of thing, that's what Boost is for, but this block is neither complicated nor particularly difficult to understand.  Hell, there are only 5 lines of actual code!  The rest is just boring, humdrum plumbing

Name: Anonymous 2007-04-06 10:23 ID:ryKTpqqR

If you're going to be a pussy about programming in C++, at least be a pussy about stuff that's interesting.


template <class Derived>
struct base
{
    void interface()
    {
         // ...
         static_cast<Derived*>(this)->implementation();
         // ...
    }
};

struct derived : base<derived>
{
     void implementation();
};


Or perhaps:


template<int dimension>
Vector<dimension>& Vector<dimension>::operator+=(const Vector<dimension>& rhs)
{
    for (int i = 0; i < dimension; ++i)
        value[i] += rhs.value[i];
    return *this;
}


(Both samples stolen from http://en.wikipedia.org/wiki/Template_metaprogramming)

Name: Anonymous 2007-04-06 13:18 ID:Heaven

>>25
is dat sum curiously recurring template pattern?

Name: Anonymous 2007-04-06 14:22 ID:oFHaIak2

>>25
Ugh, C++... Don't tell me what you've done there is basically
sum = lambda *x: reduce(lambda x, y: x + y, x)

Name: Anonymous 2007-04-06 14:46 ID:aVh39aQx

C++ is disgusting
C is better

Name: Anonymous 2007-04-06 19:13 ID:Heaven

>>28
>C++ fails
>C wins

fixed

Name: Anonymous 2007-04-07 13:53 ID:aBY0RR36

c++ metaprogramming per day keeps doctor away

Name: Anonymous 2007-04-07 14:29 ID:dTJin3ND

Some C++ metaprogramming every day makes your family lock you up in the attic...  I haven't seen the sun in five years :(

Name: Anonymous 2007-04-07 15:55 ID:Y5DF/cPv

>>3
| Stroustrup

Oh lawd. Stay far away from this book if you're a newb. It'll only scare you, and you'll never come back. It's a good book for reference, or improving skills if you already know the basics, but learning from that is a bad bad idea. There are many other texts out there that are just as good, as far as content goes, but more newbie friendly.

Name: ALAN COCKS 2007-04-08 19:37 ID:Txr6KK6V

HELLO I AM ALAN COCKS, FOUNDER AND CEO OF LINUX KERNEL BRANCHES AND BUGFIXES. I ADVISE YOU TO STICK TO C AND JOIN OUR CLUB OF HIPPY LINUX CODERS. YOU'RE GOING TO LIKE THE WAY YOU LOOK (CHECK WIKIPEDIA FOR MY PICTURE). I GUARANTEE IT.

Name: Anonymous 2007-04-08 20:51 ID:jCt4aMwr

>>32

If you don't have the balls for Stroustrup, you don't have the balls for C++.  Leave the programming to the real men.

Name: Anonymous 2007-04-08 20:54 ID:oiTczOsm

>>34
>>34
>>34
>>34
>>34
>>34
>>34
>>34
>>34

also, well C is for manly real men, C++'s just for real men

Name: Anonymous 2007-04-08 22:55 ID:VNuEd3fZ

stroustrup is a douche. Who the fuck overloads bitshift for a stream?

Name: Anonymous 2007-04-09 1:06 ID:v+7YzJyu

>>36
Someone who thinks 1 process == 1 thread.

Name: Anonymous 2007-04-09 1:44 ID:SUNp0mer

>>36
The bitshift operators look like little funnels, so it's like you're funneling data into the stream D:

Name: Anonymous 2007-04-09 1:45 ID:SUNp0mer

my ID is awesome
SUNPOMER ACTIVATE

Name: Anonymous 2007-04-09 13:53 ID:3CTkWPI2

LOL TWINKIE HOUSE

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List