Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ What Do You Find The Most Annoying About C/C++?

D

Dan-Kode

Guest
So as the Title says, what's the most annoying thing you think about for these two Languages.

For me. Pointers. I'm currently learning C, it's going over Pointers, I don't have a damn clue about them, I end up watching a Video and that Video explains them better. Why do they even exist in the first place?
 
So as the Title says, what's the most annoying thing you think about

For me it's SFINAE ("Substitution Failure Is Not An Error") in C++ templates.
It just has such a damn ugly syntax.

Here's a shortened example from a project I'm working on:
C++:
/*
 * A really complicated way of saying "T may only be string, int, or double"
 */

template<class T>
using ForceVMType = std::enable_if<
    std::disjunction<
        std::is_same<T, std::string>,
        std::is_same<T, int>,
        std::is_same<T, double>,
        std::false_type
    >::value
>;

class SomeClass {
public:
    template<class T, class = ForceVMType<T>>
    bool check(T value) const;
};
 
So as the Title says, what's the most annoying thing you think about for these two Languages.

For me. Pointers. I'm currently learning C, it's going over Pointers, I don't have a damn clue about them, I end up watching a Video and that Video explains them better. Why do they even exist in the first place?
Everything, just to print to console is hard.( i havent learned c++ yet ) but ive seen how to print to console... its overly complicated
 
Pointers. I don't have a damn clue about them.
Why do they even exist in the first place?

It's kinda funny how everyone (me included) struggles with pointers in the beginning.
They are extremely useful though and it's important to understand them, because it even helps you in high-level languages.

One metaphor that helped me in the beginning was the postal system.
I don't know if you still need this, but I'll explain it anyway for other people who struggle with this:
Your home address is like a pointer to your house.
You get an address when you decide to build a house at some point in your life (House* house = new House;).
You can duplicate/copy this information endlessly and share it with all your friends, but doing that will never build a second house.
It's just a way for your friends to know where the house is located.

In this context, "pointer arithmetic" becomes a lot simpler too.
Imagine your neighbor is throwing a party and you want to invite your friends.
You can simply tell them "come visit the house next to Example Lane 21" (*(house + 1)).

Pointer arith might seem useless at first but it's basically how arrays work.
Imagine you need to store 100 cars somewhere and lease some construction company to build garages.
They will start building them and, in C/C++-Land, tell you the address of the first garage.
(Car* first = malloc(100 * sizeof(Car)))
Now if you want to drive around in your 28th car, you just need to visit "the garage that is 27 garages away from the first one".
aka *(first + 27) or, in the more common form, first[27].

Most people don't believe this at first but array[index] is really just defined to be an alias of *(array + index) in C.
This is also the reason why arrays usually start at zero.
We already know where the first garage is, so we don't need to add anything to the array value to get it.

Also little funfact here:
Because of the way basic math works (1+2 == 2+1) we can actually flip array expressions in C.
26[array] is valid code and equal to array[26] :x3:
 
Last edited:
I make small executable programs in c/c++, to learn more about how crackmes work, by writing a bit higher level language like c and look at the dissassembly in asm/etc.

Most of my c/c++ code is smaller than a 100 lines, that works out well in the terminal, sometimes I do check out with an editor like atom,sublime text, geany,...
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom