Click here to Skip to main content
15,886,761 members
Everything / Programming Languages / C++14

C++14

C++14

Great Reads

by honey the codewitch
GFX is a fast and full featured replacement for standard IoT drawing libraries that is optimized to reduce bus I/O
by MehreenTahir
This article will show you an alternative way of using C++; How to write functional code in C++. You’ll see how to write more concise, safer, readable, reasonable code.
by David Lafreniere
A C++17 standards compliant delegate library capable of targeting any callable function synchronously or asynchronously
by Petrov Vladimir
Compact and simply Vector Formula of the Intersection Point of Two Line Segments

Latest Articles

by Bruno van Dooren
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
by David Lafreniere
A C++17 standards compliant delegate library capable of targeting any callable function synchronously or asynchronously
by honey the codewitch
Take advantage of the PlatformIO repository to easily add GFX to your projects
by honey the codewitch
A more in-depth guide to creating drivers and other custom draw targets for GFX

All Articles

Sort by Score

C++14 

8 Mar 2022 by honey the codewitch
GFX is a fast and full featured replacement for standard IoT drawing libraries that is optimized to reduce bus I/O
23 Nov 2018 by MehreenTahir
This article will show you an alternative way of using C++; How to write functional code in C++. You’ll see how to write more concise, safer, readable, reasonable code.
19 Dec 2022 by David Lafreniere
A C++17 standards compliant delegate library capable of targeting any callable function synchronously or asynchronously
5 Dec 2019 by Petrov Vladimir
Compact and simply Vector Formula of the Intersection Point of Two Line Segments
12 Jun 2019 by Michael Haephrati
A simple and easy to use InputBox() function for any type of C++ program for Windows
24 Jul 2018 by stevemk14ebr
PolyHook v2 - the C++17 x86/x64 library supporting multiple methods of hooking
21 Sep 2017 by Michael Haephrati
How to detect the currently used language regardless of the active application
16 Aug 2020 by Michael Haephrati
Desktop application that can be used to convert from and to various audio formats, such as .mp3, .m4a and .wav
3 Jun 2021 by honey the codewitch
Explore techniques for drawing using GFX
18 Nov 2017 by Mikhail Semenov
The article explains the recent Modules TS Draft for a future C++ Standard and provides examples based on the modules implementation in Visual C++ 2017
23 May 2018 by John M. Dlugosz
It is easier than ever to exploit the range-for loop (and make use of std algorithms) for things other than collections.
4 May 2021 by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
21 Apr 2022 by honey the codewitch
Take advantage of the PlatformIO repository to easily add GFX to your projects
25 Oct 2014 by Bartlomiej Filipek
A list of my top 5 interesting C++ proposals.for pre-Urbana mailing. Unified Syntax Call, Coroutines, array_view ranges and modules.
10 Oct 2015 by Afzaal Ahmad Zeeshan
Having a C program source code is not enough, you need to have a compiler too. Then, compiler would need the references (locations) where to find the headers (if there are any in the source code). Those headers need to be accessible by the compiler, to link them and create an executable. So,...
19 Feb 2016 by Aescleal
The first rule of C++ standard library use is grab a vector and use that. Only if that's too slow (or you don't have enough contiguous address space) do you bother reaching for another container.So try std::vector> stirred with a judicious use of std::sort and std::find to...
25 May 2017 by CPallini
Quote: [MarshalAs(UnmanagedType.U8)]ulong verb, [MarshalAs(UnmanagedType.U8)]ulong verb2 That should be, instead [MarshalAs(UnmanagedType.U4)] uint verb, [MarshalAs(UnmanagedType.U4)] uint verb2 or, simply: uint verb, uint verb2
11 Mar 2018 by OriginalGriff
Look at the input string: 600599598596 The first thing to do is to identify the sequence. Start by assuming the highest number has 1 digit: 6,0,0,5,9,9,5,9,8,5,9,6 Does that work? No - because you have two zeros together. So try with 2 digits: 60,05,99,59,85,96 Does that work? No - 99 is...
24 May 2018 by User 11060979
That is because most probably your return value (by value) goes into nirvana and will be destructed ... questionable ... This is the correct implementation of Operator= which will also not call the destructor: const strin& operator = (const strin &x) { cout
17 Jan 2019 by CPallini
The logic of the recursive (say) sum function is already given in the exercise text. Just the implementation is missing. Now what is exactly your problem with such implementation? If you are not able to write a recursive function, then have a look at this page: C++ Recursion - Recursive...
9 Sep 2019 by OriginalGriff
Every time you use cout it will print. It then continues to the next line and executes that. So when your code does this: cout 10) { cout 10) { ...
7 Oct 2019 by phil.o
string substr (size_t pos = 0, size_t len = npos) const; The second parameter holds for the length of the substring, not for the index of the end of the capture. std::string::substr[^] So, yes, the function is working properly; you just misused its parameters :)
29 Oct 2019 by Alexander Lednev
This is a fast binary serializer with compile-time members and version check
9 Nov 2019 by Richard MacCutchan
You obviously have not tried everything, since you have not tried Using Timers - Win32 apps | Microsoft Docs[^].
29 Jan 2021 by CPallini
Quote: void func(ENUM retCode, std::string name); What's wrong with ENUM func(std::string name); ? If you really need to return a value then return it. As an alternative you could pass an item by reference (see, for instance C++ Functions -...
27 Feb 2021 by honey the codewitch
Using a popular RTOS to enable easy multithreading on your IoT gadgets
8 Mar 2021 by honey the codewitch
Traipsing through the ESP-IDF to add some sweet sweet real-time clock functionality
10 Oct 2015 by PIEBALDconsult
I didn't find a dir.h file with my installations of Visual Studio.But Borland C/C++ has a dir.h and GCC that comes with MinGW has one.It seems Visual Studio does not have a dir.h :"I think that ANSI C does not have any directory functions, hence no dir.h and no dirent.h in Microtosoft...
22 Nov 2017 by Jochen Arndt
You can do that but it is bad style. A temporary variable should be local and not a class member: for (int i = 0; i
2 Jul 2018 by Jochen Arndt
The full error message contains more information: the name of the source file and the line number. Inspect that line and the preceeding lines, or show us the full message and indicate the line in the posted code. However, your posted code snippets should result in an error in the aliens class: ...
18 Jul 2018 by Rick York
Octal digits can range from 0 to 7. This is because octal is base 8. A literal integer value starting with 0 is considered to be octal. If it starts with 0x it is a hexadecimal value.
18 Sep 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
12 Oct 2018 by OriginalGriff
So you think the best thing to do is dump a pile of unformatted, double spaced code on us and go "you sort it out"? No. Not going to happen. We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also...
17 Jan 2019 by OriginalGriff
First let's deal with the "compilation errors": You can't just copy your homework question into a .C source file and compile it - that will never, ever work! The question is am English description of what your teacher requires the code to do, it is up to you to read the instructions and write...
25 Feb 2019 by Rick York
I think the second parameter is wrong. Here is the prototype of the function:void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* data ); The first two parameters are the location to begin...
18 Jun 2019 by Patrice T
Hint: Rather than loop on intput file and read line and store values, then loop to output file, you can merge both loops and avoid using vectors. loop read 1 line from input file decode/store values to variables write 1 line to output file end of loop Do not load a file to vectors if you...
6 Sep 2019 by Stefan_Lang
The function GetIntArrayFromCharArray creates a copy, therefore your calls to begin() and end() refer to two different arrays! This is reflected literally in the error message - all you need to do is read and understand it. ;-) [..] (cut away revised parts of the solution - see below) ...
9 Oct 2019 by CPallini
Quote: searched in internet but I don't find format that is Search in the documentation: strftime, wcsftime, _strftime_l, _wcsftime_l | Microsoft Docs[^].
16 Oct 2019 by Visweswaran N
I wrote a small helper function which will help, have added comments to help you understand. // SWAMI KARUPPASWAMI THUNNAI #include // As content of the file is in strings. #include // For file IO #include // For Matix storing #include ...
9 Nov 2019 by Greg Utas
Look at CreateEvent and WaitForSingleObject. This is what I use to provide an interruptable timer when something wants to sleep. SetEvent wakes it up before the timeout expires.
10 Nov 2019 by phil.o
The include for the map class is: #include But you may also need: #include #include if they are not already included in Player.h or GrphSettings.h.
31 Dec 2019 by k5054
Take a look here: CMake Tutorial — CMake 3.16.2 Documentation[^]. That should guide you in creating your CMakeList.txt file. Are you sure you're using cmake, though? Generating a Makefile through cmake should produce a Makefile that is many lines long. In my case, even the simplest cmake...
4 Jan 2020 by Richard MacCutchan
See notes below for points 1,2 and 3. // ... 1. for (int linenox = 0; getline (AtomId_file,line) && linenox >AtomId>>Atom_radius; } if (NB.is_open()) { 2. search = AtomId; ...
4 Jan 2020 by Patrice T
Quote: I have written the below code to fine, for example, "1" from File 1, and search it in File 2, then substitute "1" with "5.66". and repeat it for other numbers, i.e. 2,3,4,5. but I don't know why it doesn't work. Because your code is not trying to do what you say, you should reread you...
25 Jan 2020 by Richard MacCutchan
Think about the question and what you need to do: 1. Get the word in a, and the key letter in b 2. Set the flag to false 3. Create a loop that will iterate through all the letters of a 3.1. For each letter, compare it to b, and if it is lower, set the flag to true. 3.2. If the flag is now true,...
22 Feb 2020 by k5054
The problem is that the thread goes out of scope without having been joined, so the program crashes. See here[^] Assuming that this did work, you would get a crash anyway, since you have an infinite loop. Eventually you would run out of...
5 May 2020 by KarstenK
Why havent you search for the XMLString documentation??? If you dont like doing research for yourself you should consider stop coding.
2 Jun 2020 by Patrice T
Quote: i want to learn and write codes Wrong starting point, you will never learn programming by picking a random project and try to solve it. It is like trying to learn engineering by building a space shuttle from scratch in your backyard. Not...
30 Jan 2021 by k5054
pow(x, y) is going to overflow even a 64bit value quite soon - e.g. pow(500,10) = ~9.8e26, which is far larger than 2^64 (~1.8e19), so you need another approach. Math can help here: given n^x = m, to solve for x, then x = log(m)/log(n) (Try it...
18 Jun 2021 by honey the codewitch
Use GFX effectively with e-paper/e-ink displays
2 Feb 2023 by Bruno van Dooren
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
17 Jan 2024 by Bruno van Dooren
I wrote an article about that. Check it out. Using C++ Move Semantics to Manage Pointers to Externally Allocated Memory[^]
11 Oct 2015 by Patrice T
The best method is to have a teacher that adapt the method to your weakness and your strength.To learn programming, the language is not very important, just some like C and C++ are harder because they are unmanaged and that's a pitfall for beginners.Visual Basic and FoxPro are very good...
11 Oct 2015 by CPallini
Programming?You are lucky since you may find many resources (tutorials, ebooks, videos, ..) for learning programming available for free on the web. A good book (or many good books) would help in order to have a systematic grounding. Then practice, practice, practice.
11 Oct 2015 by OriginalGriff
If you can't get a course, get a book - and follow it from beginning to end, doing all the exercises, no matter how trivial they seem.If you can't get a book either, then the internet is full of tutorial web sites and video - most of which are written (or filmed) by people who know next to...
15 Dec 2015 by Are Riff
I am learning about dynamic memory and have a question.Let say I have this class.class Elf {private: double _health = 0;public: Elf(const double &health){_health = health;}};I can create an Elf object using smart pointer like this.unique_ptr vec1 =...
18 Feb 2016 by CPallini
In my knowledge there is no such a container. A simple solution, if data size isn't huge, would be using both the containers: map (or unordered_map) and map, however then you must be sure to keep them in sync.
2 Jul 2016 by Shvetsov Evgeniy
Assuming i have some function template f1:templateint f1(int i, int j) throw() { return i + j + f2(i, j);}is there way to determine if 'f2(i, j)' can be a constexpr. (no matter it is a func. or a functor) and so mark 'f1' as a constexpr. too?What I have tried:I am...
25 Jun 2016 by OriginalGriff
Indentation helps a lot when you look at code: it means you can see what is goign on a lot more clearly...But a quick glance says that the swap function:void swap(int *i,int *k){int j;// js any temperory element*i=*k;*k=j;}Is not going to work!What value do you put in k each...
16 Mar 2017 by OriginalGriff
I get:0/1 5/1 ...
20 Mar 2017 by Jochen Arndt
The error is here:m_message = new char[strlen(value + 1)];That will allocate two characters less than required (random size when the passed string is empty).It must be:m_message = new char[strlen(value) + 1];The error is also present with G++ builds but not detected.
20 Mar 2017 by CHill60
In C++ you should be usingusing namespace System::Threading;See the documentation - Thread Class (System.Threading)[^]
22 Jan 2019 by Michael Haephrati
I am posting an answer because after some research I found a way. Using my method, an icon can be used as an integral part of a static library and such library can be used by any type of application, including a console one (which doesn't have any resource segment whatsoever). 1. Icon is...
17 May 2017 by Jochen Arndt
Which compiler version (I guess Microsoft)? I have tested similar code (using other union member types) with the GNU compiler and got no errors. Depending on the C++11 support of the compiler it might be sourced be the union members being not POD data types: Union declaration -...
25 May 2017 by Pete O'Hanlon
Something you need to be aware of - DWORD depends on the Windows version. So, on a 32 bit machine, a DWORD is 32 bits. On a 64 bit machine, it's 64 bits. More importantly, a DWORD is a uint (not a ulong). Edit: As Carlo pointed out - I was thinking of DWORD_PTR, not DWORD. However, the point...
31 May 2017 by Richard MacCutchan
No, the values are both the same. It is only the string representation that is different. See What Every Computer Scientist Should Know About Floating-Point Arithmetic[^].
20 Jul 2017 by Patrice T
Quote: i ve tried but not getting exact pattern Show your code and explain specific problems to get some help. We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your...
10 Sep 2017 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
12 Oct 2017 by OriginalGriff
Quote: I would like to know how to return the false, if you may show me a sample code that'd help Try:return true; Orreturn false;
19 Oct 2017 by CPallini
(Wild guess) You wrote a console application, something like #include int main() { std::cout
15 Nov 2017 by CPallini
Basic Input/Output - C++ Tutorials[^]. Arrays - C++ Tutorials[^]. Statements and flow control - C++ Tutorials[^].
16 Nov 2017 by Jochen Arndt
See C++ Operator Precedence - cppreference.com[^]. Then break the expression down step by step according to the precedence and replacing fixed expressions (those that did not contain variables). It is often also helpful to insert parentheses first according to the precedence. If you have for...
26 Nov 2017 by Richard MacCutchan
ifstream ins.open(fileName) ; //connects ins to file inFile You cannot instantiate an object and call one of its methods in a single line like the above. It must be: ifstream ins; // create the stream object ins.open(fileName) ; // connects ins to file fileName Same issue in...
4 Dec 2017 by OriginalGriff
You have declared numtoys as an int, not an array - and you cannot index into an integer: void elfRating (int numToys, string&rating) { int t = 0 ; if (numToys [t]
11 Feb 2018 by OriginalGriff
Quote: Here's a fun problem! Goggle Translate: Quote: Here's my homework! We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and...
12 Feb 2018 by Maciej Los
You have to understand what above code does. And you have to rewrite it from scratch! In case you're lazy, you can use online converter. Note: it's not Java, it's Delphi. A list of available converters, you'll find here: .NET Code Conversion - Convert Your Code[^]
22 Feb 2018 by phil.o
There is something missing in there. char * defines the return type of the function pointer. (*) is invalid as is; if you intend to declare a function pointer, you have to give it a name, for example (*function_name) Besides, there is a closing bracket which does not match its opening one. ...
9 Mar 2018 by OriginalGriff
Don't. Converting code from C to C# will not produce good C# code - C is all pointer based, and C# isn't. C# is also class based, which C has no knowledge of. And C# uses .NET which includes a wealth of collections which already handle all "the fiddly stuff" for you - including Dictionaries,...
11 Mar 2018 by Maciej Los
In addition to OriginalGriff[^]'s solution, i'd like to provide sample code with bit of improvement. My solution is Linq based: string sentence = "600599598596"; //string sentence = "60595856"; int len = sentence.Length; int half = len/2; //here is a magic! var dividers = ...
27 Mar 2018 by KarstenK
a simple break and a bool should do be enough :-Obool flagAlpha = true; for (int i = 0; i > abc.hdhf; }
12 Apr 2018 by Jochen Arndt
Compile and run it. To know what happens at each step insert print statements showing the content of all variables inside the loops. Or do it manually by writing it down on a piece of paper or in a text file: m = 0, k = 0 v[k] = v[0] = 'A' = 64 v[k] - 'A' = 'A' - 'A' = 0 m += v[k] - 'A' -> m =...
25 Apr 2018 by Patrice T
Quote: I have no idea how to go about doing these questions. It's urgent You need to urgently study your lessons or have a talk with your teacher. We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to...
23 May 2018 by Jochen Arndt
If you declare an object on the stack as in your case, it is destroyed automatically when going out of scope. As already noted at your other question, you should pass it by reference to avoid creating a copy. So it should be: { const std::vector arr = {1, 2, 3}; doSomething(arr);...
24 May 2018 by CPallini
Copy assignment operator - cppreference.com[^].
14 Jun 2018 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send. So now...
9 Jul 2018 by Rick York
You can subtract two numbers and then test the sign of the result. A negative value means the second was larger than the first. You can determine the sign by testing the most significant bit - if it is set then it is a negative number. That can be done by masking off all other bits and...
10 Jul 2018 by OriginalGriff
Basically, don't do that! See here: Why does x = ++x + x++ give me the wrong answer?[^]
18 Jul 2018 by Jochen Arndt
C/C++ knows three types of integer literals: octal, decimal, and hex. Since C++14 there is a fourth type: binary. A literal beginning with a zero and followed by another digit is treated as octal value (base 8) which is not allowed to contain the digits 8 and 9. See also integer literal -...
26 Jul 2018 by Jochen Arndt
Let the loop run downwards. Then the exponent value can be assigned to the loop variable initially. Because you have to initialise the result too and will use exponent, this must be done after initialising the loop variable. Fortunately, C/C++ for loops allow multiple statements in the init...
11 Sep 2018 by Richard MacCutchan
You cannot allocate dynamic arrays on the stack like so: int new_arr[leng]; You must use the C++ new operator. int* pnew_arr = new int[leng];
15 Sep 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
17 Sep 2018 by OriginalGriff
Simple: the first thing your Node constructor does is try to construct a new Node instance. Which calls the Node constructor for that object instance, and the constructor tries to create another new Node instance. So the constructor is called for that one, which ... and you run out of stack...
17 Sep 2018 by Jochen Arndt
In your example * is the Dereference operator - Wikipedia[^]. Because p is of type unsigned char * it will access the unsigned char to which p is pointing. It is similar to using p[0] and *(p+1) is similar to p[1].
25 Sep 2018 by Patrice T
To help you understand what is wrong, change all the: cout
4 Oct 2018 by CPallini
Probably is due to C++ function name mangling. Try to surround function declaration with extern "C" { // your function declaration here... } See, for instance, Name mangling (C++ only) - IBM Knowledge Center[^].
5 Oct 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. And it's pretty important that you...
5 Oct 2018 by OriginalGriff
Do yourself a favour and take out the now-redundant TODO comments: if you have done it, you don't need a reminder to do it again! But ... we do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there...
19 Oct 2018 by David O'Neil
int main() { play(paper); play(something); play(scissors); play(paper); return 0; } Hope this helps get you started Or maybe it will make you mad enough to try on your own, and show this a***hole (being me) what a jerk I am by succeeding. Or at least...