because values are an evil C thing learn to program high level, sweetie
Brandon Foster
> objects literally only exist on the heap not true;
this code allocate on the stack : Nigger nigger(nigarg);
this one on the heap : Nigger* nigger = new Nigger(nigargs); delete nigger;
Lincoln Collins
Pointers decay to references in C++ why the fuck are you doing *that?
Kevin Stewart
You just use references in the function declaration and then you don't have to do any weird things in the code. Something like this is much more typical: bool some_function(const container &input_a, const container &input_b, container &output);
Juan Carter
>> objects literally only exist on the heap This is a good thing. With move semantics this is super efficient.
>> yet every fucking function takes a reference References implicitly convert to pointers? Plus references allow you to take arguments by value
>> *evetything *looks *like *this That's c
>what the fuck is it with cpp wankers and their fucking reference obsession? References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you
>> const int& GetWidth () const What's wrong ?
Carter Moore
>BOOHOO PROGRAMMERS ACTUALLY HAVE TO DO WORK INSTEAD OF RELYING ON WEAKASS NOOB GARBAGE LANGUAGES THAT GIVE PROGRAMMERS NEXT TO NO CONTROL OVER ANYTHING C or get the fuck out. >C IS BAD You don't understand C. >I UNDERSTAND C, C IS BAD You don't understand C.
Nolan Sanders
>LANGUAGES THAT GIVE PROGRAMMERS NEXT TO NO CONTROL OVER ANYTHING C++ gives you a lot more control than with C. What are you talking about?
Asher Brown
>this bait again C does not fit into all niches, some people want to write highly abstract code that still compiles to high performance machine code, some people prefer reducing development time over program runtime. To think that there is a single language that can satisfy everyone's needs is insanity. Fuck off.
Christian Reed
>two greentext arrows >space after arrows >reddit spacing
Are you fucking retarded? I was talking about one particular library, not C++ in general.
Levi Carter
Wut? Of course they don't.
Easton Harris
And this is how I know you don't understand C. If you really learn and understand C, you'll understand how fucking crippling and useless every single other language is and you won't even touch them.
Jaxon Edwards
so you're saying everyone who writes in any other language than C is wrong to code in that language?
Jace Nguyen
> References implicitly convert to pointers?
Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references?
> That's c
lmao
> References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you
Yeah, the problem is that in C++, you always have both pointers and references. Oh, and values too.
Carter Johnson
>no you don't REALLY understand C, you're wrong >no I'm not telling you what it means to understand it Do you know what the word "compromise" means? Fuck off.
Hudson Ortiz
Anyone who doesn't write C is a poo in the loo
Kayden Reyes
Must be subpar programmers using C++. I rarely need pointers in C++.
Ayden Nelson
Yes. >I want to stab you in the eyes! >I don't want you to. >How about one eye? >NO! >DO YOU KNOW WHAT THE WORD "COMPROMISE" MEANS? You're probably a fucking Pybaby. You and your fucking garbage noob language can go fuck off.
Charles White
The absolute strawman in this post is astounding. Wanna know how I can tell you've never actually worked in a real work environment? Not everything in programming is related to purely what you can do in the language, you need to also consider things like time of development and bottlenecks not related to your cpu actually processing code, like disk/network IO. In those cases, writing your code in the fastest possible language isn't necessary, and instead you can focus on making your code more maintainable or easier to add features to. Relative to other languages, C is not one where developers can quickly create programs that do what they want, the number of details you need to remember to handle that other languages simply handle for you is higher, thus C is not a good choice in these types of cases. Fuck off.
(Side note, sometimes I do wish things like python had actual pointer-like types instead of forcing you to use wrapper objects, it would be rather convenient. I'm not gonna go tear up my code base and rewrite it in C++ just so I can have it, though.)
Jackson Flores
The spaces come from OPs text, and clover makes the extra arrows. Honestly only newfags call out newfags anymore
>>Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references? >Since when? Where the fuck did more than 1 moron in this thread got the idea that C++ somehow automatically converts pointers to references?
int a; int* p = &a;
>> That's c >lmao Have you ever written any c? Even ctard agree that everything in c is a pointer (they just argue that that's okay because it's better)
>> References is what you mean to use most of the time when programming in any language, it's just that c++ actually allow you to express this manually, so that you don't have to rely on the compiler hopefully optimizing it for you >Yeah, the problem is that in C++, you always have both pointers and references. Oh, and values too. ???
Michael Parker
That's taking the address of a and assigning it to the pointer p. There is no reference in your example.
Adrian Kelly
Somehow, the library designers must have gotten the memo that one should use references everywhere, but not that they should stop using the heap for everything.
Joshua Brooks
If you really need stack allocated containers you can write your own allocator to allocate blocks on the stack and construct your containers directly in them. It's just not the typical use case for resizable containers for obvious reasons.
Caleb Torres
>stack allocated containers Container classes should be stack objects with heap pointer properties.
Thomas Cruz
The more I use C++, the more I realize that references are only good for operator overloading and only serve to obfuscate code elsewhere.
Elijah Garcia
> int* p = &a;
Do you know what a C++ reference is? Go read like the first two pages from a cpp book.
David Fisher
I only use references for short-lived input arguments, little things like Rect, Point etc, to make it easy to create and pass them inline when needed.
Aiden Stewart
I always make out args pointers, it's self-documenting. Long-living objects are passed by pointer as well (to signify that I'm not actually "sending" the object there, just offering a handle).
Oliver Reyes
Const references on function parameters are useful.
Andrew Martinez
That's not C++ that's Java++
Grayson Morris
in some cases using a ref for 64-bit objects or less (such as ints or floats) can actually be slower than just copying. const & is good practice if your tossing objects around though
Noah Taylor
the compiler will optimize out the ref
Oliver Powell
depends on the compiler. through visual studio, we got some weird results