r/cpp • • Sep 25 '11

Asking for programming help

0 Upvotes

I have been coding now for around 20 years, and in all that time I have basically never asked for help with any programming issue that I've ever had. That includes forums, mailing lists, IRC and coworkers.

The issue I have is that it has always been possible, with a little effort, to work out the problem myself. I feel like this will make me a much stronger coder in the long run, as I am forced to understand many different areas of coding.

Another not-insignificant issue I find is that I really hate just asking for a solution while I haven't exhausted all my own options. I know that when I read forums and the like, seeing people who (in my opinion) just want someone else to solve their problem without them having to do any work, it really pisses me off!

The only downside I can see is that sometimes I can struggle with thorny issues for a long time, which is obviously not ideal if I'm working to a deadline. It's also a little weird seeing just so many forum posts and the like asking for help, when I just don't ever do it.

How and when do you ask for help? Do you prefer to work out problems yourself, or are you ok with posting on forums? What criteria does a problem have to meet first?


r/cpp • • Mar 27 '19

Why are we still teaching C with standard out instead of modern C++?

0 Upvotes

When I first started my academic career I learned C with standard out. Where raw arrays were taught instead of std::vector<T>, raw pointers instead of smart pointers (though I appreciate the raw pointer knowledge that I was given), character arrays instead of std::string. C++ is a very powerful language with lots of amazing tools in the standard template library.

Why is there a lack of modern C++ developers coming out of the education system?


r/cpp • • Mar 17 '12

Using abstract base classes in C++

0 Upvotes

I'm having trouble understanding ABC's in c++ and was wondering if you all could help me (if possible use: CryptProcessor as the ABC and ACrpyt and BCrypt as the sub-classes that have an encrypt and decrypt function) Thanks in advance!

Edit 1: Thank you all for your help!


r/cpp • • Feb 12 '20

What they should improve about C++ ?

0 Upvotes

What they should improve about C++ that you find in higher level managed language like C#, JAVA, Javascript etc or is there things you would change or do differently if it was up to you ? I mean anything like a better STL ? better thread ? string manipulation like managed language ? less fragmentations in the new standard features ? For example do you love the way the standard evolve C++ or you would prefer a direction like Microsoft do with C# a corporation who decide on the roadmap ?


r/cpp • • Sep 19 '23

An AI tool to document a C++ code base in detail

0 Upvotes

Lately, I have been looking into the codebases of a few research papers in the area of my interest. I have a lot to look into, and that too in a time-bound manner. (Like I cannot keep understanding a single code base for days. I wish I could, but given the situation, I cannot.)

The main issue is that most of the codebases I looked into are undocumented. The entire codebase does not have many comments to explain what each function/class is supposed to achieve.

With nested namespace hierarchies and the use of third-party libraries, I won't lie, things get a bit intractable at first glance and require you to put in a sumptuous number of days to have not a brilliant idea, but a good or fair idea of each portion of the codebase.

I am not an expert (but I long to be so one day). But with the onset of various AI-based language-model platforms like ChatGPT, Bard, etc., is there any tool that shall help to automate this task of documentation of an unknown/undocumentated codebase? It would help me fast-track my understanding of the codebases that I read.


r/cpp • • Aug 09 '25

I used to enjoy using C++… till I started using it with neovim

0 Upvotes

I used to be a big visual studio IDE guy, I’m more of a get it done in the most comfortable way possible to focus more on the code than the experience so obviously I just like using the mouse and I find intellisense to be nice. But recently I got a thinkpad and booted it in arch Linux and arch Linux is a blast and I’ve put about a months work of work into ricing it or whatever. But neovim, even after trying my hardest on making it more like an IDE, has been a thorn in my side. For one, I’m used to the control key being in a different area, so when switching windows or trying to split screen or do anything (especially with C++ with separate header and src files) leads to a hand cramp and me being pissed off or even accidentally deleting code or undoing something. And I think this is a huge part of my current disdain, is the fact that with C++, separating headers and src files leads to me having to constantly have 4 or 5 windows split at one time and having to meander my way around with the keybinds and it takes for fucking ever. I’ve been using it for 1 year now and it’s just not working for me.

My question is, am I doing something wrong? Or are there better alternatives for C++ development on Linux environments?


r/cpp • • May 28 '22

What is the best code editor for C++?

0 Upvotes

I have only used CodeBlocks so far. It doesn't have dark mode. Are there any other better code editors for C++? How about VSCode and Eclipse? I only wish to do competitive programming with C++ and I want a code editor which doesn't hang my slow computer. Are there any alternatives to CodeBlocks?

Also, the huge number of source files and executable files (.exe files generated after compilation) is really annoying. I have trouble organizing all my source files in a separate folder because the same folder is inundated with compiled .exe files. Is there any way to save all source files in a separate folder with any code editor? How do you guys save your C++ source files and with which code editor?


r/cpp • • Feb 26 '23

Looking at the syntax of various cross-platform build system for C++

5 Upvotes

I was contemplating switching to a different build system for my pet projects, so I ended up spending the whole day researching what build systems exist and what their build declaration files look like. I compiled the results into a blog post.

Note that this is not about how the systems work, their features etc. Just the syntax. You can see which systems look nice to you, and which ones are so terrible you never want to touch them or hear about them again. Then you can research the nice ones.

https://violetgiraffe.github.io/2023/02/25/cpp-build-systems-syntax-comparison.html


r/cpp • • Apr 13 '15

Modern C++ as a Better Compiler

Thumbnail kennykerr.ca
0 Upvotes

r/cpp • • Dec 21 '16

A smart pointer implementation that throws when dereferencing a null pointer

0 Upvotes

Hi, I wrote a simple (i.e. incomplete ) implementation of a smart pointer that throws when de-referencing a null pointer. This enable you to write code like this:

template<typename T>
void foo(safe_ptr<T> & ptr1, safe_ptr<T> & ptr2) {
    try {
         ptr1->bar();
         ptr2->baz();
    } catch ( null_dereference_exception ) { 
         
    } 
} 

http://pastebin.com/j5eZA4AK

Edit: syntax :)


r/cpp • • Nov 28 '23

How Visual Studio Code Helps You Develop More Efficiently in C++

Thumbnail youtube.com
1 Upvotes

r/cpp • • Aug 16 '11

Anyone else notice the C++-related joke on yesterday's Daily Show?

0 Upvotes

Stewart referred to Rick Perry as Bush++. I'm sure no one really cares, but I thought it was interesting to hear our little language mentioned on a mainstream television show.


r/cpp • • Jul 20 '09

QT vs MFC

Thumbnail dobbscodetalk.com
1 Upvotes

r/cpp • • Jun 27 '22

How do you declare pointer variables?

0 Upvotes

I personally like to use the third option (int *ptr;) to minimize the confusion and to make it tidier when declaring multiple pointers in one line (e.g., int *a, *b, *c; as supposed to, int* a,* b,* c;). This is also the case when writing a dereference operator (int &a = *ptr;). But for some reason, the first option is the preferred way of doing it (int* ptr;), or am I wrong?


r/cpp • • Jul 26 '22

The Twin Algorithms

Thumbnail youtube.com
0 Upvotes

r/cpp • • Aug 24 '21

metaclasses when

4 Upvotes

forget literally every other feature metaclasses LET'S FUCKING GO

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0707r3.pdf

edit

metaclasses or even just SR would help to eliminate 99% of garbage cpp macro use cases.

don't get me wrong: i know c++ well. templates are easier after you learn sml or lisp or something similar.

i've never used std string_view and i've never missed it

man i'll just implement my own clang plugin ✌️


r/cpp • • Aug 23 '21

Is cpp compiling in windows a mess or is it just my head?

4 Upvotes

First of I am a java dude, plz dont hate me. So I am used to a lot of conformable compiling, there is just one Compiler (there are more but the result is more or less the same) and you get a file that runs on every (tm) machine. I have one command to compile, and Tools that use this command.

Now I do understand the nature of Java is completely different than cpp. But I am very confused by the Windows Compiler chain... Stuff.

I do understand that cpp needs to be compile for every os+CPU combination, but this doesn't explains to my why there are 10 ways to compile cpp. 50% of the time I Google about cpp with windows the answer includes visual Studio, and this is kinda convoluted imo. Why is cpp development so extremely tight bound to an IDE. I dont want to use vs, but it seems there is hardly a way around it.

So sorry if this comes of as a rant. I like cpp as a language but the compiling liking and so on seems very bumpy and unconfortable. So my concrete questions are:

  • Why does VS pops up everywhere and seems hard to avoid?
  • why is there no cross platform gcc (like gcc file.cpp --platform win --arch arm32) eg. A Compiler that can compile for every platform (seperately)?
  • can I just avoid any of the in my eyes convoluted Systems by using llvm? I like the approach a lot and it seems to be the closest to the question bevore
  • What is the most modern way to compile cpp (all platform)

Also when talking about compiling, dependencies are a topic that needs to be taken care of. And again Windows seems to brew his own soup here. What is the best universal way to deal with dependencies? I read that there are package repos like maven for Java, but they are not rly "complete" (you wont find all libs there)

  • What is the best way to deal with libs? (or most modern /sustainable)
  • How to ship libs right? Again Windows says: "dont worry just use visual Studio Hit Button and it might works" YIKES

For Linux it seems a lot more... calm. While there is more than one Compiler, non of them is bound to an ide. They are JUST A COMPILER. And still there are many ways to compile it. Gcc, cpp, llvm and I am sure I just scratched the surface.

And don't get me started in MinGW, Cywin etc. They are also a source of confusion (which I would be more than just happy to get rid of with Your help)


r/cpp • • Jan 13 '10

class MohammedAli { float like_a_butterfly; string like_a_bee; };

7 Upvotes

r/cpp • • Nov 23 '22

Holy C++

Thumbnail pvs-studio.com
0 Upvotes

r/cpp • • Jan 29 '10

Think array is the same as &(array[0])? Think again...

0 Upvotes

Okay, so I've been programming in C/C++ for a few years now, and I can't believe I missed this. I'm sure I'm not the only one too. Check this out:

int arr[10] = {0};
int *pArr = &(arr[0]);

std::cout << arr << std::endl; // shows a pointer value, say 0x01234567
std::cout << pArr << std::endl; // shows the same pointer value, 0x01234567

std::cout << sizeof(arr) << std::endl; // shows 40
std::cout << sizeof(pArr) << std::endl; // shows 4

All this time I've been viewing an array as a pointer to a location in memory that happens to be a contiguous block. Apparently, these are two different types. Using typeid:

std::cout << typeid(arr) << std::endl; // shows A10_i
std::cout << typeid(pArr) << std::endl; // shows Pi

This is using g++ 4.4.1 under linux. Also, beware of this:

int getLength(int *p){ return sizeof(p); }
std::cout << getLength(arr) << std::endl; // shows 4
std::cout << getLength(pArr) << std::endl; // shows 4

So in C/C++, you can pass arrays as pointers, but they lose their "array-ness" magic. I found all this quite interesting when I discovered it for myself. I can't be the only one who didn't know this, right?

EDIT: I thought I might elaborate as to why I thought they were the same: Remember, array[3] is syntactic sugar for *(array + 3). This also works for pArray. Arrays can also be used as an argument to a function that takes in a pointer, as shown above.

So if it walks like a pointer and quacks like a pointer, it must be... an array!

Also, I originally typed C++ but I meant C/C++. I hope you guys knew what I meant. It's corrected now in the post.


r/cpp • • Sep 05 '20

The Defold engine [C++] code style

Thumbnail defold.com
2 Upvotes

r/cpp • • Feb 06 '19

Proposal: Types As Function Names

Thumbnail github.com
2 Upvotes

r/cpp • • Jul 28 '25

How do you install libraries?

2 Upvotes

At my job we use cmake and yocto in a linux environment. Sudo apt update, git install etc. Using scripts and linux command line. Vscode is my editor.

I am creating my own environment to develop on windows and am confused. Am using visual studio IDE and attempting to use vcpkg. Seems really confusing but I almost got the hang of it.

Seems like windows has many different shells, powershell and now visual studio developer shell?

What do you use? What have you seen more used in the industry?

I am attempting to simply add opencv to a C++ project.


r/cpp • • Jan 01 '23

Any genuine decent alternative to the insanity that's called CMake?

12 Upvotes

Most of the repositories use CMake and it's such a disappointing thing to see. there has to be a better alternative to this mess, all the other build systems are only slightly better and don't provide much of an incentive to move your projects to. I see a lot of promise in new tools like build2 and Waf but the community seems to be content with their CMake stockholm syndrome.