Comment on: C++ is a pleasure to work with.
I would say it really is not; if it were, we could not have free standing functions or global variables and other fun things... But yeah you can, and should, use OOP designs in C++. C is cool, too. Especially the older versions without type checking.
Comment on: C++ is a pleasure to work with.
void recurse()
{
recurse();
}
Comment on: C++ is a pleasure to work with.
int (int arg)
{
int x;
if (arg > 0)
x = arg;
return x * x;
}
Comment on: C++ is a pleasure to work with.
Just don't go full retard on meta programming, I guess
Comment on: C++ is a pleasure to work with.
This one may be subtle, but is fairly obvious to the intermediate C++ developer.
I basically demonstrate wrong use of shared ptr:
#include <memory>
#include <iostream>
class Whatever
{
public:
Whatever(int a) : m_a(a) {}
std::shared_ptr<Whatever> getptr()
{
return std::shared_ptr<Whatever>(this);
}
private:
int m_a;
};
int main(int argc, char* argv[])
{
std::shared_ptr<Whatever> instance = std::make_shared<Whatever>(123);
std::shared_ptr<Whatever> same_but_diffrent = instance->getptr();
std::cout << "instance: " << instance.use_count() << std::endl;
std::cout << "diffrent: " << same_but_diffrent.use_count() << std::endl;
return 0;
}
Outputs:
~$ ./a.out
instance: 1
diffrent: 1
double free or corruption (out)
zsh: abort ./a.out
C++ is a pleasure to work with.
2 0 comments 14 Mar 2019 23:17 u/skruf (self.programming) in v/programmingComment on: Top or bottom? (WTF)
JS itself is very homosexual.
Comment on: Terry David says computer sciences is brain fucking the kids. Is he right?
Rest in peace, cia nigger.
Comment on: When all your senior devs leave and you're left with fucking nigger-brained idiots
no newline?
Comment on: Work as a C++ programmer
I just got very good feedback from one of the top coders, and it seems that things may go in my favor. I guess I am stressed because this is a line of work I've got no control over, yet... although work routines are falling in place now and I can be more relaxed.
Anyway, Thanks a lot for great answers from all of you! Each post have something nice. Will follow up on the books and web pages. I'm actually scouting for some material about theories around programming or computer science (such as algorithms and data structures).
Comment on: I guess he prefers Ruby
It's very easy to write 4 dimensional spaghetti code with javascript.
Comment on: C/C++ inc/decrement operator style
This is one of the things I think makes programming interesting, the different styles there is. The most interesting example I think of is Fox-Toolkit's style, the author has an, I may say, interesting style...
Comment on: C/C++ inc/decrement operator style
Even though modern compilers optimize for either of these uses, I'm sure, the idea was that when post-incrementing (i++), 'i' here will return the value and then increment it, which apparently takes more time than pre-increment (++i) where you would increment and get the new value.
C/C++ inc/decrement operator style
1 0 comments 09 Jun 2018 23:08 u/skruf (self.programming) in v/programmingComment on: Forcing women into programming is a fucking mistake
I want to point out that there's also another very fundamental thing missing here.
You never want two classes that are similar (here, Girl, Guy) to act as two very separate classes. These should be derived from a base class "Person" or something... :/
Comment on: Microsoft reckons devs would like an AI Clippy to help them write code
This is ridiculous. Work on the same project, on same machine, apparently no form of versioning control... this can be disasterous. Pointless, useless features. More reasons for me to avoid Visually impaired Studio. Even this IntelliSense is garbage. Why do you want to have "most popular methods" on the top? Just keep em all sorted A-Z... I see no form for productivity increase or anything.
Comment on: C++ Will No Longer Have Pointers
Good one. Jokes on me.
Comment on: Linus Torvalds - "That is either genius, or a seriously diseased mind."
Can confirm @7e62ce85 - however it's possible to do some really wacked shit with macros. Could be cool to experiment with, but avoid using them too much in a real project.
Comment on: Show Voat: I made a JSON tools website with a bunch of useful JSON utilities
A quick glance and it seems quite useful. Bookmarked. Thanks!
Comment on: I put this here, 'cause I know v/Programming will "approve." The James Webb Space Telescope is going to run JavaScript (PDF Warning) (No, they aren't kidding.)
Wannabe web "programmers" at it again!
Comment on: Do you hate JavaScript?
I feel you. Worth mentioning, the cancer of all is idiots using a fucking browser engine as a standalone frame, like discord, atom.io, and others. I observe that as web-developers without skills or a lack of motivation to learn new skills, attempting to write standalone programs. Feels like this could be related to some those politically correct people pretending to be coders scripters.
In my opinion, a prerequisite for learning any sort of code should be understanding x86 assembly, not meaning to learn using it to its full extent, but understand what a registry is and how they're used, difference of stack and heap, how your memory works, etc. This knowledge will teach why some failures occur and gives a completely different perspective on instructing a computer in any given language. This should also provide a good reason for why not to use a script language for more complex programs. I've never taken any classes in programming, so I'm not sure if this is even a thing. I'm self-learned in C++ though.
Comment on: C++: How do I work out the usage count of a function template?
Don't know why I did not think of this myself... well, thank you for the tip!
Comment on: C++: How do I work out the usage count of a function template?
facepalm I'm kinda slow on taking jokes. but yeah fair enough lol
Comment on: C++: How do I work out the usage count of a function template?
So you're saying this isn't really possible in C++ ?
C++: How do I work out the usage count of a function template?
1 1 comment 21 Nov 2017 13:48 u/skruf (self.programming) in v/programmingComment on: Circuits: What is your best way to make a "hard drive", or a part of the system that saves state after power is off?
As already stated, EEPROM is your go-to here, however these have a somewhat low write limit; after the limit the chip cannot be written to. The other option is to interface an SD card, which is somewhat easily done with any MCU and using a simple implementation of the FAT file system.
Comment on: Modern UI, flashy but ergonomically evil
skruf@voat-desktop:~$ man man
Comment on: Prime numbers.
Yeah I thought so aswell, the never ending discussion about making the most efficient code to a given problem!
Comment on: Prime numbers.
Apparently my approach gave me the desired results, but for not being the best maths guy, why should I do that?
Comment on: What industry do you work in?
Construction and programming could be very different; but it's kinda the same, except in programming you would use abstract concepts to build whatever.
Comment on: Microsoft and Canonical partner to bring Ubuntu to Windows 10
Well, it was posted a few days before april 1st, so I don't know. Although, I sincerly hope it was a joke.
Comment on: Microsoft and Canonical partner to bring Ubuntu to Windows 10
Embrace, extend, extinguish.
Comment on: Got a game for you low-level programming NERDS
I've seen this game before and it seems pretty cool. Never had any time to try it, or much other games for that matter.
That being said, I believe you posted in the correct subverse, it's quite relevant.
I have found Qt Creator fairly good with this issue