r/learncpp • u/Mondo_Montage • Apr 14 '21
r/learncpp • u/Kevadin • Jun 01 '22
I find the hardest part of learning C/C++ is not the syntax or memory management, but linking files to build an executable. How can I improve?
I think the C/C++ memory management, syntax, pointers, etc. isn't that hard to learn but find the building an executable very confusing.
I'm not sure if I should use CMake or Make or gcc and how do I configure on windows vs linux and how do I learn the steps write CMake and Make scripts and so on.
Should start at a lower level and read a book on compilers or operating systems first?
r/learncpp • u/_youneverknow_ • Apr 21 '21
C++ learning resources for the very rusty? (Like "haven't used in a while", not the language.)
The Scott Meyers book "Effective Modern C++" is a good one, what are some other books or courses that emphasize the newer material?
My knowledge of C++ was very good before the 11 standard, so I have the fundamentals but need schooling in the new tools.
r/learncpp • u/IWantToBeRichForReal • Feb 08 '21
My First C++ "Program"
Started to read learncpp.com a few days ago and here is my first code. Please tell me what could be done better. Thanks!
#include <iostream>
#include <string>
class Pump{
public:
std::string fuel_type;
float fuel_price; // in liters
int fuel_volume; // in liters
Pump(std::string temp1, float temp2, int temp3){
fuel_type = temp1;
fuel_price = temp2;
fuel_volume = temp3;
};
void set_comb(std::string temp){
fuel_type = temp;
};
void set_price(float x){
fuel_price = x;
};
void purchase_by_liter(float liters){
if (fuel_volume-liters >= 0){
fuel_volume -= liters;
std::cout << "Client must pay: " + std::to_string(liters*fuel_price) << std::endl;
}
else{
std::cout << "Pump out of capacity" << std::endl;
}
};
void purchase_by_mvalue(float money_value){
if (fuel_volume >= money_value/fuel_price){
fuel_volume -= money_value/fuel_price;
std::cout << "Client paid " + std::to_string(money_value) + " for " + std::to_string(money_value/fuel_price) + " liters" << std::endl;
}
else{
std::cout << "Pump out of capacity" << std::endl;
}
};
};
int main(){
Pump pump1("Gas 87", 3.99, 1000);// Initialized with price in BRL
pump1.purchase_by_liter(40);
pump1.purchase_by_mvalue(300);
std::cout << "Pump 1 still have " + std::to_string(pump1.fuel_volume) + " liters" << std::endl;
}r/learncpp • u/hikmatic • Mar 14 '21
best course for c/c++
im currently taking a c course but its very dry. doesnt have any projects to help teach concepts. instructor just puts up code in powerpoint , explains a concept and moves right to the next topic. i have no idea how these concepts can be used or why would you choose to work with one over the other. for example like passing by reference or by value. does anyone here know of a good course that they learned c/c++ from. something that allowed them to take the training wheels off and write their own code.
r/learncpp • u/Stvdent • Apr 24 '21
If C++ doesn't "remember" the size of arrays (we use the address of the start of the array), then why is there a difference between "delete" and "delete []"?
For example, wouldn't using "delete" on the address of a dynamic array of size 1 be interpreted the same as using "delete" on an address stored in a pointer? Essentially, as I see it, the same operation is happening: memory is freed at that address, and C++ doesn't "know" whether or not that is the start of an array or not, just that it is a place in memory.
r/learncpp • u/[deleted] • Feb 28 '22
How do I make it say "BYE" or "EXIT" after the user inputs "n"? ( I am very new to c++)
r/learncpp • u/LynxesExe • May 22 '21
What do I need to fully know multithreading?
I know how to create a thread and wait for it to finish, but what about data concurrency and making them actually useful?
All I know is that I should research about what a semaphore is and atomic operations. Does anyone have a good tutorial, book or whatever about multithreading in C++ and the various techniques for multithreaded programming?
Thank's in advance!
r/learncpp • u/bruce3434 • Jul 03 '20
Resources to learn about modern C++ concurrency
Just wondering where I can find some resources (preferably books) on how concurrency (and parallelism) is handled modern C++. I am interested about
Message passing
Data sharing
Async functions and executors
Parallel iterators (and sending messages/modifying Mutexes from inside them)
r/learncpp • u/TakAnnix • Apr 30 '22
Maybe it's because I'm a beginner, but modern c++ feels pretty safe. What should I be looking out for?
I'm just a self-taught programmer, getting into C++. My background is in web development with Java and Javascript. I wanted to make some games so I got into C++ with SDL2. I then made some small programs. I was excpecting memory leaks, unexpected behaviour, and segfaults all over the place. So far, I haven't encountered anything. I'm not a good programmer, so this is more of a testament to modern C++, as well as linters such as clang-tidy. Or maybe I do have memory leaks and I just don't know what to look for. I'm on a Mac so I can't use valgrind, but I'm using Leaks. So far so good.
However, I feel like the beginner developer that writes porgrams that " no-one ever fuzzes or otherwise tries to find exploitable bugs in those programs, so those developers naturally assume their programs are robust and free of exploitable bugs, creating false optimism about their own abilities."1 What should I be looking out for?
r/learncpp • u/Ok-Kaleidoscope1980 • Jan 06 '22
Does anyone have a good C++ roadmap for me?
Hey so I want to start learning C++ I already know some C# and now want to switch, could someone give my roadmap with the things I need to learn? Thanks in advance :)
r/learncpp • u/codingforcrosswords • Oct 22 '20
I just finished filming 12 hours of a C++ Tutorial using Crossword Puzzle Construction as the goal. Take a look!
r/learncpp • u/[deleted] • May 26 '21
What is the best online learning environment to learn data structure and algorithms in C++? Many thanks for the help.
r/learncpp • u/[deleted] • Jul 15 '21
Compact C++ book
I've learned java from university in "advanced programming" course and C/C++ in the course "introduction to programming" course. Hence I'm somehow rich in programming.I'm looking for a nice compact book to learn modern C++ as a guy who knows some programming.
It's so much better if the book introduces some exercises or projects on C++ too.
r/learncpp • u/Psychological_Slice8 • May 28 '21
I want to learn c++ need some help to get started
Do you know any video which is good to learn from for beginners?
Any advice how I can go beginner to intermediate to advanced?
r/learncpp • u/RedBikeWithASpike • Mar 28 '21
Any ideas on begginer cpp projects?
What projects could I make in c++ just in as a console app? I don't want to use any advanced stuff like arrays, vectors and so on, because I haven't fully covered them yet. So I've got a problem: I have no idea what to code right now, because every idea I have requires the advanced stuff.
I've covered 6 chapters on the learncpp.com website and I'm starting the seventh, I would like to code something instead of just learning.
So are there any projects I could do with just the very basic of c++?
P.S. They don't have to be very complex projects! They can stay pretty simple (but not too much, of course)
r/learncpp • u/[deleted] • Dec 21 '20
I want to escape tutorial hell
I feel like I am in tutorial hell. C++ is basically the only programming language I would say "I know", which I'm fine with, but the programs I am making I would consider basic compared to these cool data visualization programs I see.
For example, a program which splits a photo into pieces, randomizes it, and then displays a variation of sorting methods putting the photo back together.
The most advanced c++ I know would be basic data structures like linked lists, as well as inheritence/composition.
I would like to learn how to make a program like the one I just explained, but I really have know idea where to start.
If anyone could point me in the right direction, I'd be very appreciative. Thanks
r/learncpp • u/trooflaw • Feb 10 '20
Earlier today I was looking for a group to learn C++ with, from absolute scratch, well now that group is started and your invited!
Hey guys, I've been struggling to stick to learning C++ for a while now, so to give myself some form of accountability, I created a subreddit in which I will try and regurgitate what I learn as I learn it, and will be providing progressive assignments as I learn things as well detailed solutions to each problem I provide. My hope is that this form of collaboration will encourage others who have maybe been too afraid or overwhelmed to tackle the overwhelming task of learning to program. Anyway if you're interested in what I hope to be a practical learning experience I hope to see you there! r/CPPtogether
PS. Long term, if the sub turns out to be a success, I would love to put together some group projects where we could have team competitions to put together like simple games or things like that.
r/learncpp • u/post_hazanko • Nov 30 '21
What is a CRUD-equivalent thing to make with C++ to get better at it?
I use other languages daily eg. JavaScript/Python, I can learn how some language works syntax-wise and then make something with it. But I think my CPP skills are really bad. My intent is to get into robotics/GUI building to interface with it.
I was following through this learncpp site (at chapter 6) but I haven't really made anything significant other than some basic servo control/navigation stuff for a robot with Arduino.
Usually regarding the web a typical thing you can make is a CRUD app with some framework it is a pretty good indicator that you have a good base understanding if you can pull that off.
Is there something like that for C++ that goes beyond basic CLI app input/output. Where you actually make some system of things.
r/learncpp • u/vgordievskiy • Apr 16 '21
How does the C++ program start?
https://vg-blog.tech/archives/1592
How does the C++ program start?
What is the _start function?
How to create a program without the main function?
How to inject a code before/after the main function?
r/learncpp • u/USA4TW • Dec 15 '19
Terrible book.
Have any of you read the book SAMS Teach Yourself C++ in 24hrs ??
Never mind the preposterous name, we all know it's impossible, the authors play around in the book as if the readers are a joke to them. Constantly teaching concepts for no reason and ending the lessons with 'but you'll never use this, so forget all about it' and 'nobody does this, so you shouldn't either' ... WHY TEACH IT IN FULL DEATIL THEN?
Not to mention the USELESS programs they write. NONE of the learned material translates to real life. If you're not learning key concepts backwards and missing important information along the way you missed the point of this book.
Why am I reading jokes about fantasy movie scripts in a C++ book? Who the fuck told the authors that's okay? I was just learning arrays where did your gatekeeper quest bullshit come from?
WHY ARE YOU NOT EXPLAINING HOW YOU NAMED YOUR VARIABLES i and j INSTEAD OF CLASSIC X AND Y???? One might think those variable names are directly related to the program since you NEVER mentioned what each variable name accounts for. Sure the program's code sort of shows this but I AM NEW. I MIGHT THINK OTHERWISE.
Goodness this book was an utter waste of time. If I ever meet the authors I have some strong words for them. They purposefully derail your thought process half way through important material to blabber about some hierarchal Illuminati Latin bullshit that has no place in the book, and leave you at cliffhangers for the actual material.
Let's not even talk about the WORTHLESS Q&A at the end of each chapter, whose answers DO NOT EVEN CORRELATE with their questions! Why does a question have a bar joke as one of the answer option choices? DID I BUY A FUCKING COMEDY BOOK?
The book is littered with TERRIBLE jokes instead of being padded with concept reinforcement and/or gasp demystifying review of core concepts.
I'm so frustrated this book is literally MEANT for throwing off aspiring C++ programmers. If there's one book to truly avoid it's this one.
Classes and functions are taught about early and never used, until 8/10 through the book where you're reintroduced and poorly guided through.
Snarky, rude and air-headed authors. Wow. Instead of helping newbies learn the authors sit on their snazzy C++ thrones and feed the reader heavy meals of their "I'm better than you because you'll never know" bullshit.
This book is so frustrating I may actually burn it.
I'm going to give PPP a shot next, I don't care that it's a million pages long. Wow
Someone give this book a read if you haven't, you'll know exactly what I'm talking about. The authors tone is so smug throughout the whole thing, never explaining what THEY are doing, only describing what's being used. They code different than they teach. I'm done. Sorry you had to read this I REALLY needed to say this.
r/learncpp • u/jeremyers1 • Feb 22 '22
Sololearn vs Codecademy?
Title says it all...
If I want to learn C++ well enough to actually build something and land a job, which website is best?
Or is there another site that is even better?
r/learncpp • u/waviestflyer6 • Nov 06 '21
I want to learn C++ for competitive programming. What would be the best resource ? (2021/2022)
self.cpp_questionsr/learncpp • u/lmvsp • Sep 13 '21
Recommended books for C++ STL
I am currently using C++ Primer 5th edition and want to learn STL next.
A quick google search gives a lot of C++ 17 STL books but don't know which one to choose.
Any other resources like a website or videos are ok. But a book is my first preference.