C++ thread?

C++ thread?

Other urls found in this thread:

godbolt.org/
pastebin.com/bHj5XFGm
pastebin.com/3B9164sR
pastebin.com/Re5FCsRM
pastebin.com/QKdVaKSF
pastebin.com/en8pmwAQ
pastebin.com/xiznGvn6
youtube.com/watch?v=xnqTKD8uD64
pastebin.com/DxmZ1ed7
pastebin.com/ZSJi3Hjj
pastebin.com/Wd8F5ASH
pastebin.com/FJa0Wjm7
tutorialspoint.com/tutorialslibrary.htm
twitter.com/SFWRedditVideos

C thread?

Why not both?

Bow before your new god.
godbolt.org/

Being really good at C++ is like being really good at using rocks to sharpen sticks. – Thant Tessman
Arguing that Java is better than C++ is like arguing that grasshoppers taste better than tree bark. – Thant Tessman
There are only two things wrong with C++: The initial concept and the implementation. – Bertrand Meyer
C++ has its place in the history of programming languages. Just as Caligula has his place in the history of the Roman Empire. – Robert Firth
C++ is history repeated as tragedy. Java is history repeated as farce. – Scott McKay
C++ is like jamming a helicopter inside a Miata and expecting some sort of improvement. – Drew Olbrich
C++ is the only current language making COBOL look good. – Bertrand Meyer
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. – Bjarne Stroustrup
C++: Simula in wolf’s clothing. – Bjarne Stroustrup
C++ will do for C what Algol-68 did for Algol. – David L Jones
Historically, languages designed for other people to use have been bad: Cobol, PL/I, Pascal, Ada, C++. The good languages have been those that were designed for their own creators: C, Perl, Smalltalk, Lisp. – Paul Graham
I consider C++ the most significant technical hazard to the survival of your project and do so without apologies. – Alistair Cockburn
If C++ has taught me one thing, it’s this: Just because the system is consistent doesn’t mean it’s not the work of Satan. – Andrew Plotkin
If you think C++ is not overly complicated, just what is a protected abstract virtual base pure virtual private destructor and when was the last time you needed one? – Tom Cargill

But, why? Just use objdump...

I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. – Alan Kay
It has been discovered that C++ provides a remarkable facility for concealing the trival details of a program – such as where its bugs are. – David Keppel
Java is, in many ways, C++–. – Michael Feldman
Java, the best argument for Smalltalk since C++. – Frank Winkler
PL/I and Ada started out with all the bloat, were very daunting languages, and got bad reputations (deservedly). C++ has shown that if you slowly bloat up a language over a period of years, people don’t seem to mind as much. – James Hague
The last good thing written in C++ was the Pachelbel Canon. – Jerry Olson
To me C++ seems to be a language that has sacrificed orthogonality and elegance for random expediency. – Meilir Page-Jones
Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, “OK, we’ll do them both”. So the language is too baroque for my taste. – Donald E Knuth
Within C++, there is a much smaller and cleaner language struggling to get out. – Bjarne Stroustrup
{Major-Willard} C++ damages the brain … – EWD
C++ is the best example of second-system effect since OS/360. – Henry Spencer
C++ is an insult to the human brain – Niklaus Wirth
All new features added to C++ are intended to fix previously new features added to C++ – David Jameson
C++: glacial compiles, insane complexity, impenetrable errors, laughable cross-platform compat, basically useless tools. – Aaron Boodman
Life is too long to know C++ well. – Erik Naggum
If you like C++, you don’t know C++. There’s a mutual exclusion going on here, and I’ve yet to see a counter-example other than possibly a few of the members of the standards committee. – ssylvan in reddit.

Oh, definitely. C++ may not be the worst programming language ever created, but without a doubt it’s the worst ever to be taken seriously. – Mason Wheeler
C++ is to C as Lung Cancer is to Lung.
I think maybe the guy who invented C++ doesn’t know the difference between increment and excrement. – smcameron
C++ is more of a rube-goldberg type thing full of high-voltages, large chain-driven gears, sharp edges, exploding widgets, and spots to get your fingers crushed. And because of it’s complexity many (if not most) of it’s users don’t know how it works, and can’t tell ahead of time what’s going to cause them to loose an arm. – Grant Edwards
C++: an octopus made by nailing extra legs onto a dog. – Steve Taylor
I believe C++ instills fear in programmers, fear that the interaction of some details causes unpredictable results. Its unmanageable complexity has spawned more fear-preventing tools than any other language, but the solution should have been to create and use a language that does not overload the whole goddamn human. – Erik Naggum
I may be biased, but I tend to find a much lower tendency among female programmers to be dishonest about their skills, and thus do not say they know C++ when they are smart enough to realize that that would be a lie for all but perhaps 5 people on this planet. – Erik Naggum
C++ is a language strongly optimized for liars and people who go by guesswork and ignorance. – Erik Naggum
c++ is a pile of crap. – Theo de Raadt
With C++, it’s possible to make code that isn’t understandable by anyone, with C, this is very hard. – Mike Abrash
Whenever I solve a difficult problem with C++, I feel like I’ve won a bar fight. – Michael Fogus
C is C++ without the BS. – SocialPhatology
[keeping somebody] from using C++ makes me feel like I saved a life – aiju
C++ is probably the only language where the error [message] can be longer than the program – aiju

General question: comparing the C++ standard library with the Rust standard library, the C++ standard library feels like complete and utter shit. I often end up having to write my own functions for really basic stuff that you'd expect to be standard, or at least not shit.

From what I've heard, lots of large organizations tend to come to the same conclusion and maintain their own standard library instead of using stdlib. Do any of you guys have experience with alternative standard libraries for C++ which is worth sharing?

Personally, I've had some experience with QT, but not much else, mostly just single-purpose libraries.

My fav from "how do shoot yourself in the foot in various programming lanaguages" - C++:
You accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical assistance is impossible since you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."

>I still think C++ > C

People generally use Qt or boost (or both).

I think people judge languages by the types of problems they are typically asked to solve with them.

>tfw to intelligent to learn c++

been using C++ for over 15 years (professionally for about 9)...
and i still love it!

- RAII
- SFINAE, type traits and general template metaprogramming
- value, move, reference and pointer semantics
- rule of 0, 3, 4 and 5
- STL containers and iterators
- template argument deduction and substitution

just a few of my favorite features, there are a lot more though!

>I think maybe the guy who invented C++ doesn’t know the difference between increment and excrement. – smcameron
my fucking sides

Using boost is fine, but most of the time it's too much for what I need, so I end using simple lightweight libraries (usually header only) for specific purposes. For example if I want to work with UTF I use utfcpp, and if I want do extract a file I use zlib, etc...

Sepples is really comfy.

>It has been discovered that C++ provides a remarkable facility for concealing the trivial details of a program - such as where its bugs are
This is really solid

Learning C++ at libtard school right now that somehow managed to get a decent engineering department.
For some reason I wrote code that not even my professor or any of my TAs can figure out the problem, keep getting a segmentation fault.
If pastebin it would anyone care to look?

This reminds me of something funny that happened a while ago in CS class back in high school.

>doing presentations on certain programming languages
>some girl starts talking about C++
>calls it Ctt
>I die on the inside
>look at my teacher
>he can't stop cracking a smile

any tips/tricks for someone coming from C, I've only briefly touched C++ in the past and all features are quite overwhelming, with what to do and what not to do. both from C and old C++ ways of doing things. any tips on where to start? books? material?

>60017802
>none of these faggots get it

post it

Just write exactly like you would in C but use C++'s strings and default function parameters.

what about the deal with pointers? is it acceptable to use them as I would in C?

Use smart pointers, but don't overuse them.

bait.
use smart pointers for managing resources.
raw pointers are good for passing optional parameters.
use references for pretty much everything else (not primitives, of course).

the most important thing is to not treat c++ as "ca with classes". c++ has changed a lot in the past 20 years.

If you just want to allocate a struct or object on the heap, you can use unique_ptr instead of raw pointers. That way it gets cleaned up automatically when it goes out of scope.

You can also use shared_ptr which provides refcounting (so never dangles), but unlike unique_ptr it has a significant runtime cost. Unique_ptr will cast automatically into a shared_ptr if you pass it to anything that requires the latter.

Main.cpp: pastebin.com/bHj5XFGm
student.cpp: pastebin.com/3B9164sR
student.h: pastebin.com/Re5FCsRM
sudentList.cpp: pastebin.com/QKdVaKSF
studentList.h: pastebin.com/en8pmwAQ
studentProfs.txt: pastebin.com/xiznGvn6

I'm only a student, so a lot of this stuff is from copying down (writing it out, not just copy paste) from his sample code. But as far as they're concerned I shouldn't be getting a segmentation fault error. Any help would be appreciated, and if you have a price just name it.

Which is the best GUI for c++ that works with the 3 major OSes? (Botnet, linux, and normieshit)

Can someone explain me Botnet and linux?
Currently use Windows because fuck you makes shit easier, but I would like to get more hardcore.

>comparing the C++ standard library with the Rust standard library, the C++ standard library feels like complete and utter shit
Rust homosexual detected

have you analyzed where the segmentation fault happens?

Botnet = Windows, bc all your data goes to Micro$oft

But my original question, which GUI framework is best?

QT is a fairly popular option, but it is really huge and you typically end up bundling your binaries with a bunch of huge .dlls.

QT creator is best IDE though. You can make GUI's by dragging and dropping components to generate the C++ code.

Dunno how to do that. Like I said, noob student.
Unless you mean just looking at the code itself, then yeah I've been doing that for the past week.

start commenting your code. it's one of the most important things in programming.

what's your program supposed to do?

Fair enough.

What is uTorrent written with?

wxWidgets. Most permissive license available, doesn't try to replace the STL and is generally not shit, i.e. the exact opposite of Qt.

Just fucking post it, maybe I can have a laugh looking at it

Sorry, I've been meaning to get to that. I'm the only one ever working on my projects so I've yet to hit the incentive to do so.
Essentially, it reads from .txt file and stores information on each student in first an object then a vector of objects. It should also have the functionality to process the scores, but right now I just need to store the information.

Plain Win32 I'd say.

>all those people
literally whos
>C++
most widely used programming language

Does it work with Linux?

Does it have networking?

It's fully cross-platform and has networking, yes.

But the STL is shit. Replacing it is a perfectly reasonable goal.

what do you use for compiling?
all your methods in the student class don't return a value, it shouldn't even compile.

I've been compiling on the school's server remotely using PuTTY
It compiles fine, but can you elaborate on not returning?

Thanks! How fast is it? Obviously non-suited for AAA games, but where would you put it on efficiency?

i now realized those methods are all setters. they don't need a return value, so they can be void functions.

Some of its standard library is used in emulators, which require high performance. PCSX2, RPCS3 and Dolphin all use wxWidgets because it's simple and fast. I know that's rather anecdotal, but I don't have any figures to give you.

Example: Let's say I want to do something as basic as split a string. The C++ standard library's answer to this is to let the user write his own function to do that.

With QT... you just call .split() on the string.

your compiler shouldn't allow omitting a return statement, it's undefined behaviour.
do you have a basic understanding of functions and function return types?

You're completely missing the point of C++.
It's more powerful, you can do a lot more with it, but with greater power comes greater responsibility.
With more tools you have more to keep track of. It's not supposed to have a bunch of automated stuff.

C is more powerful than C++.

What do you mean? Like do I know how to use them?
I know functions/methods are so that you don't have to write the same bit of code five hundred times, and if you write an int function you NEED to return an integer value, same with char, string, float, etc.

lol

But I don't want to implement unicode strings and regexp matching on them myself. That is completely and utterly stupid for the vast majority of applications.

That and Qstring has much better performance than std::string for most operations.

C++ is just C with a giant shit on it's back. Everything runs slower.

>std:string
>he doesn't implement using namespace std;

exactly, but your methods in
pastebin.com/3B9164sR
have types like "string" and "int" but don't return anything.
you should write them as "void" methods anyway, so you don't need to return anything.

anyway, i've been running your code and after it reads the first student from the file and i press any key it runs in what seems like to be an endless loop and prints out some numbers and a students name. is that the correct behaviour?

...But the single best feature of C++ is that the terrible standard library is not imported by default.

>le c++ is slower than c meme
Once C++ introduced move semenatics I couldn't go back to ancient C.

I see, I'll make those changes then. I was under the impression you didn't even need a return statement, just a return statement of the same data type.

That was another issue I had. For some reason .clear and .ignore aren't doing their jobs?

Pretty cool shit, thank you.

> int student::setTestScores(int tScores[])

ffs, learn C before going to C++

Let's say you want to handle signals(7), and you want these handlers to call the destructor method of an instance of one of your class.
How would you do it ?

Daily reminder
bool a[32];

Will implement a 32 byte structure on the stack. It's time to switch to Ada.

use bitfield struct in C

this is syntactically incorrect?

I don't mean to be rude, but is this your first time programming?

It's logically wrong. You don't pass an array. You pass a pointer. Just because it compiles doesn't mean it's right.

That syntax is complete fine and should just work.

>he doesn't know about bitfields in c++

No, but like I keep saying this is my learning how to C++. I do not have experience with the language itself but I've been experimenting with programming since high school (mainly the usual normie/basic shit like python, PHP, html/css/js, etc)

A lot of compilers will just add return or return 0 automatically if it isn't explicitly coded.

Input:
#include

using namespace std;

void doStuff(vector& v)
{
for(auto&& i : v)
{

}
}


Output:

doStuff(std::vector&):
push rbp
mov rbp, rsp
sub rsp, 64
mov QWORD PTR [rbp-56], rdi
mov rax, QWORD PTR [rbp-56]
mov QWORD PTR [rbp-8], rax
mov rax, QWORD PTR [rbp-8]
mov rdi, rax
call std::vector::begin()
mov QWORD PTR [rbp-32], rax
mov rax, QWORD PTR [rbp-8]
mov rdi, rax
call std::vector::end()
mov QWORD PTR [rbp-48], rax
jmp .L2
.L3:
lea rax, [rbp-32]
mov rdi, rax
call __gnu_cxx::__normal_iterator::operator*() const
mov QWORD PTR [rbp-16], rax
lea rax, [rbp-32]
mov rdi, rax
call __gnu_cxx::__normal_iterator::operator++()
.L2:
lea rdx, [rbp-48]
lea rax, [rbp-32]
mov rsi, rdx
mov rdi, rax
call bool __gnu_cxx::operator!=(__gnu_cxx::__normal_iterator const&, __gnu_cxx::__normal_iterator const&)
test al, al
jne .L3
leave
ret
std::vector::begin():
push rbp
mov rbp, rsp
sub rsp, 32
mov QWORD PTR [rbp-24], rdi
...
(Lots more)

WTF i hate C++ now! They told me vectors were zero cost abstractions!

Your code is a mess. There's no structure, no comments, there are pitfalls everywhere (i.e. passing raw pointers to functions and iterating over them blindly).

I never said I was good at programming. I'm just learning this shit dude.

>Having 32 elements in a struct

>-O3
doStuff(std::vector&):
rep ret

Looks zero cost to me

I liked this talk by Herb:
youtube.com/watch?v=xnqTKD8uD64

BUT MUH C

Not that guy, but I looked it over real quick.
You need to make your setters into void functions since they don't return any value (do that for any function that doesn't need to return a value).
Also, your dummy input on line 65 in your main is causing a read error, so you should replace it with a string to get whatever those codes are next to the students names before the grades.
Aside from that, you've got an infinite read loop going on the while statement in line 60 somehow.

I need a book or a site where I can practice c++ problems. Like you are given a task and you can see the solved task later. (Currently reading ''Effective C++ 5th edition'')

pastebin.com/DxmZ1ed7
pastebin.com/ZSJi3Hjj
pastebin.com/Wd8F5ASH

Also, the studentList class is useless.

You never read the first name from the file.
When you hit line 68 for the first time, you try to read "XPQ23456" from the file as an int, which obviously fails, and it sets failbit on the file stream. From then on it just loops and loops, immediately failing every read because failbit is still on, until the vector exceeds its maximum size and crashes the program or the program itself hits some memory limit and is killed by the OS

Oh, I see what's going on with that infinite loop.
You're reading the name twice during your while loop, so you're getting a cin error and its never reading the end of file character. Delete that one right before the end of the loop and it works fine.

pastebin.com/FJa0Wjm7

Why the nop's? For what purpose would the compiler introduce nop's?

Hackerrank. solutions are usually in the comments.

tutorialspoint.com/tutorialslibrary.htm

This isn't exactly that, but its bretty gud

Bjarne Stroustrup created C++

works for me ;)

you just have proved you they are all unknown, except bjarne whose name you've recognised

i was responding to this user:

>moving the goalposts
You said all those people are literally whos. Well that isn't true if at least one isn't a literally who. Bjarne isn't a literally who, therefore suck my dick faggot.

wow, there is a massive difference between -O2 and -O3
int fac(int num) {
if(num == 1) return num;
return num+fac(num-1);
}

It's right tough