[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

C++ thread?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 175
Thread images: 15

File: c++logo.jpg (4KB, 118x118px) Image search: [Google]
c++logo.jpg
4KB, 118x118px
C++ thread?
>>
>>60017724
C thread?
>>
>>60017724
>>60017751

Why not both?
>>
Bow before your new god.
https://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
>>
>>60017775

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
>>
>>60017724
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.
>>
>>60017724

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
>>
>>60017831
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!
>>
>>60017819
>I think maybe the guy who invented C++ doesn’t know the difference between increment and excrement. – smcameron
my fucking sides
>>
>>60017831
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.
>>
>>60017802
>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?
>>
File: 1481820718764.png (440KB, 1000x800px) Image search: [Google]
1481820718764.png
440KB, 1000x800px
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
>>
File: 1482691780807.jpg (92KB, 1280x720px) Image search: [Google]
1482691780807.jpg
92KB, 1280x720px
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?
>>
File: hesgoingalloutbait.jpg (36KB, 625x626px) Image search: [Google]
hesgoingalloutbait.jpg
36KB, 625x626px
>>60017778
>>60017802
>60017802
>>60017819
>>60017831
>>60017893
>none of these faggots get it
>>
>>60021528
post it
>>
>>60021591
Just write exactly like you would in C but use C++'s strings and default function parameters.
>>
>>60021638
what about the deal with pointers? is it acceptable to use them as I would in C?
>>
>>60021670

Use smart pointers, but don't overuse them.
>>
>>60021638
bait.
>>60021670
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).
>>
>>60021591
the most important thing is to not treat c++ as "ca with classes". c++ has changed a lot in the past 20 years.
>>
>>60021670
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: https://pastebin.com/bHj5XFGm
student.cpp: https://pastebin.com/3B9164sR
student.h: https://pastebin.com/Re5FCsRM
sudentList.cpp: https://pastebin.com/QKdVaKSF
studentList.h: https://pastebin.com/en8pmwAQ
studentProfs.txt: https://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)
>>
>>60021773
Can someone explain me Botnet and linux?
Currently use Windows because fuck you makes shit easier, but I would like to get more hardcore.
>>
>>60017778
>>60017802
>>60017819
>>60017831
>comparing the C++ standard library with the Rust standard library, the C++ standard library feels like complete and utter shit
Rust homosexual detected
>>
>>60021770
have you analyzed where the segmentation fault happens?
>>
>>60021811
Botnet = Windows, bc all your data goes to Micro$oft

But my original question, which GUI framework is best?
>>
>>60021773
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.
>>
>>60021835
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.
>>
>>60021770
start commenting your code. it's one of the most important things in programming.

what's your program supposed to do?
>>
>>60021855
Fair enough.

What is uTorrent written with?
>>
>>60021840
wxWidgets. Most permissive license available, doesn't try to replace the STL and is generally not shit, i.e. the exact opposite of Qt.
>>
File: 1425884368140.gif (494KB, 500x324px) Image search: [Google]
1425884368140.gif
494KB, 500x324px
>>60021528
Just fucking post it, maybe I can have a laugh looking at it
>>
>>60021882
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.
>>
>>60021886
Plain Win32 I'd say.
>>
>>60017778
>all those people
literally whos
>C++
most widely used programming language
>>
>>60021887
Does it work with Linux?

Does it have networking?
>>
>>60021946
It's fully cross-platform and has networking, yes.
>>
>>60021887
But the STL is shit. Replacing it is a perfectly reasonable goal.
>>
>>60021908
what do you use for compiling?
all your methods in the student class don't return a value, it shouldn't even compile.
>>
>>60021972
I've been compiling on the school's server remotely using PuTTY
It compiles fine, but can you elaborate on not returning?
>>
>>60021960
Thanks! How fast is it? Obviously non-suited for AAA games, but where would you put it on efficiency?
>>
>>60021908
>>60021972
i now realized those methods are all setters. they don't need a return value, so they can be void functions.
>>
>>60022008
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.
>>
>>60021967
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.
>>
>>60021997
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?
>>
>>60022051
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.
>>
>>60022097
C is more powerful than C++.
>>
>>60022087
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.
>>
>>60022118

lol
>>
>>60022097
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.
>>
>>60022155
C++ is just C with a giant shit on it's back. Everything runs slower.
>>
File: smugIndex.jpg (18KB, 249x249px) Image search: [Google]
smugIndex.jpg
18KB, 249x249px
>>60022171
>std:string
>he doesn't implement using namespace std;
>>
>>60022127
exactly, but your methods in
https://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?
>>
>>60022206
...But the single best feature of C++ is that the terrible standard library is not imported by default.
>>
>>60022184
>le c++ is slower than c meme
Once C++ introduced move semenatics I couldn't go back to ancient C.
>>
>>60022217
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?
>>
>>60017775
Pretty cool shit, thank you.
>>
>>60022217
>
int student::setTestScores(int tScores[])


ffs, learn C before going to C++
>>
>>60017724
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.
>>
>>60022320
use bitfield struct in C
>>
>>60022262
this is syntactically incorrect?
>>
>>60021770
I don't mean to be rude, but is this your first time programming?
>>
>>60022353
It's logically wrong. You don't pass an array. You pass a pointer. Just because it compiles doesn't mean it's right.
>>
>>60022368
That syntax is complete fine and should just work.
>>
File: 1471213148481.png (113KB, 360x270px)
1471213148481.png
113KB, 360x270px
>>60022320
>he doesn't know about bitfields in c++
>>
>>60022361
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)
>>
>>60022242
A lot of compilers will just add return or return 0 automatically if it isn't explicitly coded.
>>
>>60017775
Input:
#include <vector>

using namespace std;

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

}
}


Output:

doStuff(std::vector<int, std::allocator<int> >&):
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<int, std::allocator<int> >::begin()
mov QWORD PTR [rbp-32], rax
mov rax, QWORD PTR [rbp-8]
mov rdi, rax
call std::vector<int, std::allocator<int> >::end()
mov QWORD PTR [rbp-48], rax
jmp .L2
.L3:
lea rax, [rbp-32]
mov rdi, rax
call __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator*() const
mov QWORD PTR [rbp-16], rax
lea rax, [rbp-32]
mov rdi, rax
call __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator++()
.L2:
lea rdx, [rbp-48]
lea rax, [rbp-32]
mov rsi, rdx
mov rdi, rax
call bool __gnu_cxx::operator!=<int*, std::vector<int, std::allocator<int> > >(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > > const&, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > > const&)
test al, al
jne .L3
leave
ret
std::vector<int, std::allocator<int> >::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!
>>
>>60022431
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).
>>
>>60022581
I never said I was good at programming. I'm just learning this shit dude.
>>
>>60022339
>Having 32 elements in a struct
>>
>>60022448
>-O3
doStuff(std::vector<int, std::allocator<int> >&):
rep ret

Looks zero cost to me
>>
>>60017724
I liked this talk by Herb:
https://www.youtube.com/watch?v=xnqTKD8uD64
>>
>>60022690
BUT MUH C
>>
>>60022640
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'')
>>
>>60021770
https://pastebin.com/DxmZ1ed7
https://pastebin.com/ZSJi3Hjj
https://pastebin.com/Wd8F5ASH

Also, the studentList class is useless.
>>
>>60021770
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
>>
>>60022816
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.

https://pastebin.com/FJa0Wjm7
>>
>>60017775
Why the nop's? For what purpose would the compiler introduce nop's?
>>
>>60022957

Hackerrank. solutions are usually in the comments.
>>
>>60022957
http://www.tutorialspoint.com/tutorialslibrary.htm
>>
File: programming challenges.png (302KB, 1920x1080px) Image search: [Google]
programming challenges.png
302KB, 1920x1080px
>>60022957
This isn't exactly that, but its bretty gud
>>
>>60021918
Bjarne Stroustrup created C++
>>
File: hmmmm.png (309KB, 665x857px) Image search: [Google]
hmmmm.png
309KB, 665x857px
>>60022406
works for me ;)
>>
>>60021918
you just have proved you they are all unknown, except bjarne whose name you've recognised
>>
>>60023590
i was responding to this anon:
>>60023351
>>
>>60023590
>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.
>>
>>60017775
wow, there is a massive difference between -O2 and -O3
int fac(int num) {
if(num == 1) return num;
return num+fac(num-1);
}
>>
>>60022368
It's right tough
>>
>>60023359
This is working on many layers, tbqh.
>>
>>60022368
But it works and is correct tho
>>
>>60023351
Why is he shitting on his own creation
>>
>>60024824
Because it came after him and demands he create a bride for it but he refuses and is being chased down to the ends of the earth.
>>
>>60021877
You need to learn how to use valgrind and gdb. Your school is absolute shit if they haven't at least mentioned them.

Two things you can do while programming to help limit bugs and make debugging easier are 1. program incrementally (and test frequently) and 2. use plenty of print statements. It's important to always know what your code is doing and often times you can spot bugs quicker by seeing the contents of your variables as your program runs.
>>
>>60017765
Cuz seples is garbage.
>>
right now I'm designing a heap in C++ using vectors and string rather than int and I have no idea how to implement it, do i just use void Insert(string element) rather than int?
https://pastebin.com/D5jgVdxQ (embed)
i get an error when i try to use void insert(string element), feeling lost right now
>>
>>60023359
SYSTEMS LANGUAGE
Y
S
T
E
M
S

L
A
N
G
U
A
G
E
>>
>>60021570
I cringed hard reading your green text. I hope that was intentional!
>>
What IDE should I use on Ubuntu?
>>
>>60017751
>>60025712
>>
File: 1484981082868.png (924KB, 7528x2744px) Image search: [Google]
1484981082868.png
924KB, 7528x2744px
>>60023241
>not posting the latest version
>>
>>60023128
what code produced nop's?
>>
C++ has good parts and bad parts.
No one is forcing you to use the bad parts. Use the right tool for the right projects.
>>
What should I be working on? Im a noon to c++.
>>
>>60028791
i think one of the fair criticisms is that dumb people use the bad parts in your projects though.
>>
>>60028118
>>60023241

roll
>>
>>60029647
>dumb people programming
>blame the language
No.
>>
>>60029647
This is one reason Enterprise loves Java.
>>
>>60028791
But it manages to screw up parts that are good in every other language.
>>
>>60023359

Just use std::bitset. You can't have a plain old array type that's bit addressable, but you can with a type that is designed for this shit.

>>60028077

If you really feel you need an IDE, use Qt Creator. Otherwise, just use a text editor. Simple stupid.

>>60029647

Just don't hire dumb people.
>>
C++ noob here.

Question. I have a QT project with a main.cpp and two classes which are declared in A.h and B.h and implemented in A.cpp and B.cpp.

Class A has an instance of B as one of its fields, so it has B as a dependency.

Everything works fine when I put A and B in the same file, but when I try to split it into separate files I can't seem to be able to invoke the proper incantations to not get a long list of cryptic linker errors.

I'm using qmake and msvc. I'm mostly getting LNK2019 errors. I can pastebin everything if it helps.
>>
>>60031022
QMake file: https://pastebin.com/YBCj3KJu
main.cpp and headers: https://pastebin.com/8dEp30RD
cpp files with class implementations:
https://pastebin.com/K6aWHnZp
>>
>>60031267
Example of error I get:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl MineSweepState::MineSweepState(int,int)" (??0MineSweepState@@QEAA@HH@Z) referenced in function "public: __cdecl mineSweepWidget::mineSweepWidget(int,int)" (??0mineSweepWidget@@QEAA@HH@Z)
>>
>>60017831
C++ stdlib is.. special. It's moreso a library for people to use to write their own libraries. It's also very conservative, and slow to adopt new things.

That's why Boost was created -- it's the de facto standard C++ library, meant for "end users" and to satisfy needs of modern C++ programming.

A lot of companies use their own libraries over STL because historically a lot of vendors and fucking sucked, and it might've worked great on your work station, but then you send the code to someone else, they compile it against the STL they use, and they think you're the worst fucking programmer now and never do business with your company again. Now it's become a tradition to not use STL.
>>
>>60031361
Nevermind, I solved it. It magically works when I put the helpf functions in their own header file.
>>
>>60017724
Complete beginner here, never programmed trying to learn C++. Has anyone learnt using Stroustrup Programming Principles and Practice Using C++?
>>
>>60023128
Memory alignment. You'll see them above critical loops, functions, or static data. As far as I know it's because when the processor fetches the instructions it will take something like to the nearest 16 bytes and process them in parallel. So, if the instruction's memory address is something like 0xFFFF it'll only load a single byte but if it's 0xFFF0 it'll load the full 16 bytes in one clock cycle. Data is aligned to prevent cache line splits.
>>
>>60032963
I liked that book a lot, and I used it together with Effective modern C++ by Scott Meyers.

I had experience with a bunch of other programming languages before that though. I've heard some beginners complain about stroustrup's book, but really C++ itself is so complicated and hard to teach in the first place that I sincerely believe it is the least bad option.
>>
>>60017905
meh ppl just use non retarded qt binding anyway
>>
>>60032963
try an easier language like python
then learn java, and finally C++
may sound tedious, but it's the smoothest approach towards understanding programming
>>
File: DOM26YZ.jpg (76KB, 576x524px) Image search: [Google]
DOM26YZ.jpg
76KB, 576x524px
>>60017724
>tfw having to use C++98
>>
What is the best way to learn Boost as a beginner? I've done a few small projects with the STL and QT but I haven't dipped my toes into Boost yet. It looks huge and intimidating to me.
>>
>>60030629
>A bitset stores bits (elements with only two possible values: 0 or 1, true or false, ...)
What a "useful" and "powerful" "feature"
>>
>>60028118
roll roll
>>
File: sq1d.png (22KB, 164x88px) Image search: [Google]
sq1d.png
22KB, 164x88px
Is F# a meme language?
>>
>>60017778
>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
Why are Scandinavians always so macabre?
>>
>>60033683
Boost is a bad idea desu
>>
>>60022320
Is bool really defined to be a byte? I thought for sure it left the compiler room to optimize it.
>>
>>60033683
There is no reason to "learn Boost". When you need a part of Boost, you read the API reference for that part. If you "learn Boost" you'll have a solution looking for a problem and start to sprinkle that shit in when it's not necessary.
>>
>>60032963
Do the Harvard CS50 class on EdX
Its free, its teaches you the underlining ideas of programming in general using C.

Its a at your own pace "class" in the way that it gives you problems as "homework" which you can turn in and get a grade. Its seriously good though.
>>
>>60017724
>C++ thread?
Absolutely not.
>>
>>60035643
Sepples doesn't have a bit type, so I don't know how it would
>>
>>60035894
Doesn't need one. You could easily make bool only garaunteed for 1 bit. All the code would be the same but instances where you convert bool to other types would be undefined. Extracting 1bit could still be done legally where necessary it's just a little bit more onerous.

Seems to me they shouldn't have had a bool type at all if this wasn't the design. Like C.
>>
>>60035966
Most processor architectures use word-sized booleans, afaik. Having bit-sized booleans would be a major problem.
>>
>>60035990
It's an optimization the compiler can do if appropriate. Just like it can promote signed ints quite trivially to 64bit ints. More often than not in other code I write I find that being cache conscious is more important. A shift and a mask is very cheap. Especially by statically known integers.
>>
>>60036026
Vectors of bools are defined to [s]be a lie[/s] take up one bit per element afaik, if that's what you are looking for.
>>
>>60036120
But using that all your code has to be manually optimized for this case. Again that's no the problem. We all know how to write the code but giving the compiler opportunities is important.
>>
>>60017724
Is there any good IDE's and compliers for C++ || C?

I remember years ago watching videos from the newboston for C++ and somebody over there suggested one that was free and easy to install for windows.

Also isn't that why C and C++ never really picked up for modern developers? I mean just to create a GUI application in Java you need to do like three things and import a library. I really hope I am wrong but for the life of me I can't even get borlands C++ for Dos 6.22 to install and compiler correctly. Thank good C has the Arduino IDE, so thankful for that like microcontroller.

I feel like linux is my only option.
>>
>>60036247
I'm a jetbrains fan so I'll recommend CLion, QT Creator is also very good.
>>
>>60036152
>> Compiler being able to promote values of one type to values of a larger type.

Terrible idea.
>>
>>60036300
Except it's already in the language and it's great fucking idea anon.
https://youtu.be/yG1OZ69H_-o?t=2420
Example.
>>
>>60022206
you are fucking retarded if you do this
>>
>>60036278
>CLion
This looks pretty cool but is it a one time purchase? Or if they release a new version do I have to buy that like with visual studio.
>>
>>60023359
either you forgot a typedef or you create an instance of your struct called "st" and never use it
>>
>>60036334
Just because it is done doesn't mean it is a good idea to use numerical types of unknown size for anything except pointer-sized variables.

It's an even worse idea than name mangling.
>>
>>60036362
I'm afraid I can't give you any information on that, I have it free due to my university license.
>>
File: 1479219500380.gif (2MB, 400x225px) Image search: [Google]
1479219500380.gif
2MB, 400x225px
>>60036300
>He doesn't know his CPU is literally doing that right now
>>
>>60017724
what are some public-domain libraries people would enjoy? i really enjoy creating small libraries and open sourcing them for the community
>>
>>60035574

Well yes, there are some people who want to store a ton of boolean values in a compact form, as Anon was doing with his bool arrays. The bitset class does exactly that.
>>
>>60036582
what about vector<bool>???? :^)
>>
>>60036426
That's cool thanks for showing me this, it seems like a good purchase. *I've been know to buy books that are 50 plus just because I think I might need them so something like this actually has value.
>>
>>60036582
What if you want to pack a value that's not a boolean. Maybe 2, 3, or dare I say 4 bits?
>>
>>60036654

wrap your own structure because your use case is unique
>>
>>60036593

If the number of bits needed can be known at compile time, bitset is better than vector<bool>, since the bits are not stored on the heap. If you need an unbounded sized bitvector, vector<bool> is better, since it can resize itself.

>>60036654

Then you would need to be designing your own type.
>>
>>60017775
what's this?
>>
>>60036749
>>60036691
I think that was the whole point
>>
>>60036387
It's the category of things that the compiler should be allowed to deal with more
Implied in BOOL is that you only wanted a true and false state. Why wouldn't you embrace that and let the compiler deal with it? As it is now it's a very half-assed type.
I agree that it's pretty wild to do these things but since we're already in this situation why not make bool what it implies it is.
>>
>>60036247
code::blocks
>>
>>60036247
YouCompleteMe and VIM is amazing
>>
C++ reeeeeee
>>
>>60036844
C++ doesn't have the necessary expressiveness for this whole concept. I also don't think it's wild to want an order of magnitude less space for a data structure.
>>
>>60037147
When I said it was wild I was talking about the general idea of having a 'low level language' (as C++ is regarded) have all these rules that makes it not so high level, even when you ignore all the big idea features like template, operator overloading. C++ sprawls too much. It has all the concerns of high level languages and the concerns of low level languages and doesn't excell in either case.
>order of magnitude
It's both less and more than that. 8 is not an order of magnitude. But it's also the case that if you compress these bools you get cache performance bonuses that way outweigh the space they took. In many cases it can be way more than 10x improvements, though they're not consistent everywhere.
>>
>>60037222
I think that's most people's frustration with this language and why I don't use it given the choice.

I was referring to binary magnitude, but on a multi demential array it can easily go beyond a difference of several Decimal magnitudes.
>>
Boost or no Boost?
Thread posts: 175
Thread images: 15


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.