Click here to Skip to main content
15,891,248 members
Everything / Programming Languages / C++11

C++11

C++11

Great Reads

by Shao Voon Wong
Floating Point Format For C++ and C# Programmers
by Michael Chourdakis
An easy locking class for shared/exclusive mutex functions with upgrade/downgrade
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 Shmuel Zang
This article shows how we can implement a thread-safe events (similar to .NET events) mechanism using the standard C++ library.

Latest Articles

by PJ Arends
An MFC CWnd derived grid of user definable tiles
by Shao Voon Wong
Bring your animations to H264/HEVC video using C++ and C# with h/w acceleration
by Piotr Grygorczuk
Enable C++11 multithreading features in GCC for FreeRTOS
by Shao Voon Wong
H264/HEVC Video Encoder for recording OpenGL rendering

All Articles

Sort by Updated

C++11 

4 Apr 2024 by Tony Dean 2022
I may have found a solution... First, using the resource editor, I set the "Control" and "Control Parent" properties of the child dialog to TRUE. Then, when creating the child dialog, I used SetWindowPos() and set pWndInsertAfter to point to...
4 Apr 2024 by Pete O'Hanlon
You shouldn't need to hack around programatically to get this working. While I haven't done this in a while, I remember that I used to have to call ::SetParent to set the parent dialog, this including the child into the normal flow. Something...
4 Apr 2024 by Tony Dean 2022
I have an MFC dialog which contains an embedded, borderless child dialog which itself contains some additional edit controls (similar to using frames in Visual Basic). While MFC manages the tab order of controls within the dialog itself, controls...
16 Mar 2024 by Line Item
I would try running this from a command line, with some adjustments for that to make it a simple command. Get that to work then add to that a little at a time. Maybe then try moving that to PowerShell. Get that to work then add more until you...
5 Mar 2024 by PJ Arends
An MFC CWnd derived grid of user definable tiles
26 Jan 2024 by Member 16190445
This is from the 2024 January USACO Bronze Contest, which runs from January 26 to 29. As stated in the rules for Contest Conduct and Academic Integrity, Quote: Consultation about the contest problems with people other than the contest director is...
26 Jan 2024 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...
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[^]
17 Jan 2024 by mathiv327
Hi, i know how move cons syntax for static memory allocation. but here dynamic memory allocation have tried but user define is not called. can u help me for user defined move constructor for pointer.?? What I have tried: have tried in static...
15 Jan 2024 by ASHISH JHA from Delhi
Yesterday I came across the following question in a contest: Problem statement: You are given an array ‘A’ of ‘N’ integers numbered from ‘0’ to ‘N - 1’ and a single integer ‘K’. You have to determine the count of subsequences where the length...
27 Dec 2023 by Richard MacCutchan
See B2 User Manual - 1.84.0[^].
27 Dec 2023 by Member 15872449
I am using centos 5.11 with gcc-4.6.3 support ,I need to build boost thread library(version 1.82) using the same gcc without upgrading . What I have tried: The commands I used are ./bootstrap.sh ./b2 But running the bootstrap command I am...
18 Dec 2023 by merano99
A possible solution could be to write several subroutines that find all areas with ones in a given string, a program that determines given string, a program that determines whether there have been infections overnight and then, of course one that...
17 Dec 2023 by Member 16165259
Your last two points aren't necessarily correct. For instance, consider the starting position 01000001000 11100011100 11110111110 So clearly there were two original cows which is neither x nor 1.
17 Dec 2023 by Bruno van Dooren
What is this, is the entire class posting to get us to make their homework for them?
17 Dec 2023 by User 16126649
Farmer John has N cows in a line (1≤N≤3⋅10^5). Unfortunately, there is a sickness spreading throughout. Initially, some cows start off infected. Every night, an infected cow spreads the sickness to the cows on their left and right (if they...
17 Dec 2023 by Richard MacCutchan
See How do I solve this problem for all constraints[^] for suggested solutions. https://www.codeproject.com/script/Answers/Post.aspx?aid=5374347# [edit] Quote: I needed to solve this question using C++. The choice of language is not important....
17 Dec 2023 by Richard MacCutchan
This is the same issue as How do I solve this problem for all constraints[^]. You just need to adjust for the asparagus growing, rather than the candy canes shrinking.
16 Dec 2023 by KarstenK
You should use some "divide and conquer" strategy to solve that problem. To do it you should write different functions for every criteria. Best is to think about some data structure like an array of cows for the data on which your functions are...
16 Dec 2023 by merano99
The first thing you notice about the code is that the indexes extend beyond the end of the arrays: ll heightcow[n] = { 3, 2, 5 }; ll heightcane[m] = { 6, 1 }; ll finalcow[n]; for (ll i = 1; i
10 Oct 2023 by OriginalGriff
this always refers to the current instance of the containing class. Think of it as a car: you have your car, I have my car. If you put your mobile in the glove box of your car, you don't expect to find it in the glove box of my car because you...
10 Oct 2023 by CPallini
Please, feel free to Google for the many, many available resources about this very topic on the web. See, for instance: The this pointer | Microsoft Learn[^].
10 Oct 2023 by KarstenK
You must understand that pointers are ONLY some memory address like a city address. And you must know what type of data or objects you may find there. Like the city address may be a house, a parking lot or only some bushes. So when you have some...
10 Oct 2023 by mathiv327
Hi, am trying to learning this pointer in much deep results am missing something. can u help me for that depth. My understand, 1). This pointer will holds the object of address, that address pass into the non-static function. 2). we can delete...
25 Apr 2023 by Shao Voon Wong
Bring your animations to H264/HEVC video using C++ and C# with h/w acceleration
30 Mar 2023 by Piotr Grygorczuk
Enable C++11 multithreading features in GCC for FreeRTOS
16 Feb 2023 by Ernest Nowalk
Write a C++ program that prompts a user to enter a four-digit integer and prints the number in reverse. HINT: Print one digit at a time, starting from the right of the number. Sample run of program: Enter a four-digit number: 3412 Your number...
16 Feb 2023 by KarstenK
Try with starting some Learn C++ tutorial or some video tutorial. I strongly recommend that you take the time to read my tips to learn from my experiences in that industry. some tips: use functions and classes with understandable names and...
16 Feb 2023 by OriginalGriff
Start by thinking "how would I do that manually?" Write the number on a blackboard then take the lowest digit out and write that down, then rub it out. If there are any digits left you do it again until there aren't. So you need three things: 1)...
4 Feb 2023 by Gautam Saini
I am new in NamedPipe concept on Linux/Centos 7. I want to implement read write funtions between my Windows and CentOS PC using NamedPipe. I have created a NamedPipe on CentOS PC using mkfifo function and written some text on this pipe. On other...
4 Feb 2023 by longjmp
After reading the documentation on linux FIFO, I think it should not be able to interconnect with windows named pipes over the network because windows puts objects in \\.\pipe\ namespace, and linux doesn't have a special namespace for...
1 Feb 2023 by k5054
Named pipes are only used for communication between processors on the same computer. They do not provide any network capabilities. Consider that on your linux system you create a named pipe: int pipe = mkfifo("fifo1", 0777); When your program...
5 Dec 2022 by Harsh 5
The question is straightforward but the only thing I cannot conquer is getting the elf's calorie data as input from the user. I have to read for a new line and whenever I get a new line I have to update my sum to the maximum calorie/sum an elf...
5 Dec 2022 by merano99
Saving the calories in a vector would be a good idea. std::vector numbers; Then it would be practical to write the calories as described in a file calories.txt and read this file line by line. At each blank line write the sum into the...
5 Dec 2022 by OriginalGriff
Quote: The below code is what I have tried but it's entirely wrong! Yes. It is. And you don't know why. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your...
27 Oct 2022 by Death Smoke
Hi all, I Searched how to delete a whole key from the Registry using c++ anyone here can help me because i didnt find any clear example about this subject. the key path is like here : Computer\HKEY_USERS\folder \folder\ folder\{Key name}. So...
26 Oct 2022 by Shao Voon Wong
H264/HEVC Video Encoder for recording OpenGL rendering
25 Oct 2022 by Michael Haephrati
In the code below you can see how to delete a subkey or the entiry key HKEY hKey = NULL; long lReturn = RegOpenKeyEx( HKEY_USERS. _T("folder \folder\ folder\{Key name}"), 0L, ...
20 Oct 2022 by Rick York
Have you investigated the RegDeleteKeyExA function (winreg.h) - Win32 apps | Microsoft Learn[^] ? Here is another sample : Deleting Registry Key with Subkeys Win32 C program example[^]
19 Oct 2022 by Death Smoke
I Want to convert the output of this code to string type , but i cant make it. #pragma warning(disable : 4996) #include int main() { char cmd[10]; strcpy(cmd, "dir"); system(cmd); } What I have tried: I tried to...
19 Oct 2022 by CPallini
Are you possibly searching for popen? See, for instance: The Marvelous popen() Function | C For Dummies Blog[^]
19 Oct 2022 by Alexandrnn
#include #include int main() { system("dir"); puts((char*)stdin); } #include #include #include int main() { char cmd[10]; strcpy_s(cmd, 10, "dir"); system(cmd); puts((char*)stdin); }
16 Oct 2022 by merano99
The command system() creates a new process to handle the specified command. char cmd[10]; strcpy(cmd, "dir"); system(cmd); In most cases, this is neither performant nor useful. But of course you can start a process with C this way. You could...
16 Oct 2022 by Shao Voon Wong
C++11 Range For-Loop to Enumerate Registry, Folder and WMI
5 Oct 2022 by heisnberg
Write a function that returns the sum of multiples of 3 and 5 between 0 and limit (parameter). For example, if limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20. What I have tried: i don't know what is logic behind this...
26 Sep 2022 by Death Smoke
I'm trying to make a connection between two computers both of them are using tp-link adapter , but i'm not receving anything from client . #include #include using namespace std; int main() { ...
23 Sep 2022 by Member 15777477
def sum_of_multiples(limit): sum=[] for number in range(1, limit): if number%3 == 0: sum.append(number) if number%5 == 0: sum.append(number) print(sum) sum_of_multiples(int(input("enter the...
18 Sep 2022 by Death Smoke
#pragma once #include using namespace std; namespace Project1 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace...
18 Sep 2022 by Member 8840306
I am new in qt c++. I am trying to load blob image which is stored in .bin file in phpmyadmin db .That .bin file store blob image in form of string like BM6 ect(each .bin have 3 to 4 char). Here is my code that execute on button click driver...
18 Sep 2022 by Rick York
BM6 is the header of a bitmap file, followed by a double quote character - 0x22. Following the 0x22, there are four nulls. You can not expect to copy a bitmap's binary data using strncpy because there are null characters in it and they will...
14 Sep 2022 by Death Smoke
The Code dont print the Blankspace when I type it between words in the message getline it only print first word or last letter but if i write between words any character like -./\_ it will print the full message , Example : -Without character: I...
14 Sep 2022 by Rick York
jeron1 gave you the answer. Here are a couple of references you should consult to verify what was stated : operator>> (string) - C++ Reference[^], this one describes the redirection operator and this one : istream::getline - C++ Reference[^]...
15 Aug 2022 by n.deny
i am trying to read and Write the data from microcontroller to c++/cli application using protocol . Write data were successfully done but i am unable to received the data. What I have tried: private: System::Void...
15 Aug 2022 by Richard MacCutchan
Take a look at Serial Port I/O[^] which explains how best to use the serial ports.
11 Aug 2022 by Arvind Anuchaa
How to learn CSS coding, without learning html5? What I have tried: If I'm not a specialist in HTML.
27 Jul 2022 by merano99
In fact, there are many ways to read a byte from a file under Windows with C or C++. Actually, they should all work if the file is readable and not empty. Most system or library calls have return values ​​or return the number of data read or...
27 Jul 2022 by Member 15078716
I have studied this for about 3 years and I have not found anywhere in books or on the internet that tells me how to do this. Never. I am using codeblocks 17.12 with gcc 5.1 set for UTF-8 on Windows. What I have tried: Everying that I thought...
25 Jul 2022 by Richard MacCutchan
Or in C++ you could use the get function of ifstream: std::basic_istream::read - cppreference.com[^]. Quote: I have studied this for about 3 years and I have not found anywhere in books or on the internet that tells me how to do...
25 Jul 2022 by OriginalGriff
Quote: My compiler: "error". "error". "error". "[Ha ha ha, another]error". First off, if you get compilation errors, then that is to be expected - but we can't help fix them without seeing the code and the error message(s) any more than a...
5 Jul 2022 by merano99
This question seems to be a very popular Homework. There also seems to be a solution for a fee....
5 Jul 2022 by Member 15697402
USE DEV C++ MENU TYPE FOLLOW INSTRUCTIONS MACHINE PROBLEM A new video store in your neighborhood is about to open. However, it does not have a program to keep track of its videos and customers. The store managers want someone to write a...
5 Jul 2022 by KarstenK
Try with starting some Learn C++ tutorial or some video tutorial. some tips: use functions and classes with understandable names and install some IDE like Visual Studio.
5 Jul 2022 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...
4 Jul 2022 by Bugs Founder
I am using std::pair when I try to insert integer data as value it is working well but when I try to use string data as value it is not working details below ``` #define __CONFIGSERVICE_H__ #include "toml.hpp" #include #include...
28 Jun 2022 by sirun wang
here is code snippet i try to compile, which result to compile error: convert const char * to int is invalid; can anyone help debug this code ? thanks in advance! What I have tried: #include #include using namespace...
28 Jun 2022 by OriginalGriff
The string "sir" is not a number: you can't add it to an integer directly, and there is no way to convert "sir" to a number at all!
27 Jun 2022 by Shao Voon Wong
Example of making HTTP REST Request in C++
22 Jun 2022 by Cricket HiLites
The problem terminates before taking any input. What could be the possible reasons for that? I am very new to competitive programming. Currently, I am learning Vector in STl. What I have tried: #include using namespace std; ...
22 Jun 2022 by CPallini
The program, tested on my Linux box, runs correctly: it takes the input and produces the output. Check your execution environment.
22 Jun 2022 by Huyền Nguyễn 2022
Given an integer sequence consisting of N elements a1, a2, … , aN and Q queries, each query is an integer K. Requirements: For each query, determine the longest consecutive subsequence on the sequence A such that all the elements of that...
22 Jun 2022 by Patrice T
Quote: I tried to use DSU but no success This is a typical problem from a challenge site, the rule of thumb is that the solutions are never 'there is a standard feature that give the answer', you always have to craft the solution with an ad hoc...
21 Jun 2022 by CPallini
You know, it reduces in finding the indices of the items a[i] satisfying a[i] >= k. Once you have them, you may find the result as max(a[i+1]-a[i]+1).
18 Jun 2022 by Bugs Founder
I am using toml++. How can I modify a particular value of a TOML file in CPP using toml++ json ConfigService::getAllData(std::string filePath) { try { auto _data_table = toml::parse_file(filePath); ...
18 Jun 2022 by Richard MacCutchan
The error message is stating the the element at _data_table["config_paths"] cannot be an integer. You need to consult the documentation for the _data_table class to find out why.
22 May 2022 by Member 15645256
The following codes can be executed correctly,and print 1 2 3 std::allocator alloc; auto begin = alloc.allocate(3); std::vector ivec = { 1,2,3 }; std::uninitialized_copy(ivec.begin(), ivec.end(), begin); for (auto q...
22 May 2022 by steveb
reserve() does not change the size of the vector. You need to use resize(3)
22 May 2022 by Phoenix Liveon
�����Is there a way to have this initialization block similar to Java that we could implement and run properly in C++. There were two types of init-block in Java: 1. init-block/raw-init-block, this will invoke at every new instance created. 2....
20 May 2022 by Member 15078716
I have been programming in C++11 on a 32 bit Windows operating system. When I run the program it is difficult for me to follow what it is doing. I am now attempting to have my program open up Wordpad seperately and write to Wordpad as my program...
20 May 2022 by Rick York
To answer a specific question asked in your code : "Quote: How do I send a wide string instead of a single character? You can't. Windows SDK calls that accept strings require it to be passed by address and that address must be of memory...
20 May 2022 by OriginalGriff
What you are trying to do is a very old fashioned way of debugging a program - and it's called "logging" and should probably be sent to a file directly instead of messing around with external apps, as that adds significant overhead and may make...
26 Apr 2022 by Rishabh Vishwakarma 2022
int Priority(char x){ if (x=='+' || x=='-') return 1; else if (x=='*'||x=='/') return 2; else if (x=='^') return 3; else return -1; } int InfixToPostfix(char expression[]){ char *e,x; ...
26 Apr 2022 by Rick York
The problem a string literal value is constant and the function is not set up for that. Here is how you can fix it : int InfixToPostfix( const char expression[] ){ const char *e; Stack stack(10); e=expression; ...
17 Mar 2022 by PBSG
I have product ID and vendor ID using these i need to access the comport and also display the port name and number in c++ can anyone help in this topic there are many examples in c# but i need them in c++ for the project What I have tried: i...
16 Mar 2022 by honey the codewitch
Get your data on, even on platforms without a reliable STL implementation using these simple but critical classes.
18 Feb 2022 by merano99
As has been suggested several times, a graphical output would look much better and represent the proportions much better. In C++ this could look like this with GDI+: void MyDraw1(HDC hdc, int start_x, int start_y, double size) { using...
17 Feb 2022 by amin.j
I want to draw a triangle with sides 3, 4 and 5 in C++, however I have some difficulty.How I can adjust the character * to have a nice shape of triangles with exact size 3 , 4, and 5. Here, just seems the sides are 4, 4, and 5 whereas I want to show 3, 4 and 5. Is it...
16 Jan 2022 by kavinderrana121
I was reading Minimum spanning tree - Kruskal with Disjoint Set Union - Competitive Programming Algorithms[^] and I am confused in below operator overloading part used in above implementation,here how we can sort without defining the comparator. How is sorting taking Place over two...
16 Jan 2022 by Member 15502389
And that's already working code for Kruskal algorithm for finding MST (obviously using Disjoint Set Union) struct Edge { int u, v, weight; }; bool comp(Edge e, Edge f) { return e.weight edges; int n, m,...
16 Jan 2022 by Member 15502389
Hello, there is another method to sort vector of edges: struct Edge { int u, v, weight; }; bool comp(Edge e, Edge f) { return e.weight edges; sort(edges.begin(), edges.end(), comp); After you define struct,...
5 Jan 2022 by WOLF 2018
Hello I have been searching for 5 hours trying to find away to get process info and startup info but failed to find any infomation on it. LPPROCESS_INFORMATION lpPI, LPSTARTUPINFO lpSI; HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, false,...
5 Jan 2022 by Rick York
There are a few ways you can do this. One is call OpenProcess and it requires a process identifier as an argument so you have to obtain that first. Generally speaking, that's what needs to happen : you first need get a process identifier and...
5 Jan 2022 by Stefan_Lang
You seem to try and imprint another languages' properties onto C++, and that is never a good idea! My experience with java is limited, and I'm not sure what you actually have in mind, but the code you posted is clearly not the recommended way of...
5 Jan 2022 by Phoenix Liveon
What I did for now was to call/invoked it inside of the first line of one of any constructor, Note: upon by doing it we need to have a delegated constructor if we do had multiple overloaded constructors, so that we could link it together, then...
31 Dec 2021 by Richard MacCutchan
You could probably simplify that by the use of the singleton pattern - Google Search[^].
31 Dec 2021 by CHill60
We are more than happy to help those that try for themselves but we will not write your homework for you. It doesn't do you any favours and just makes the next exercise even harder for you to complete (your tutor will assume you don't need any...
31 Dec 2021 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
30 Dec 2021 by Krayfighter
I have an application that uses cppyy. I have a header file containing a wrapper for sfml's RenderWindow so that the python instance can access those graphics. The C++ header file graphics.hpp with the following contents #include...
30 Dec 2021 by Krayfighter
I have searched for a while and found that the sfml shared objects had to be loaded into the context of the python script I made a new file "graphics.cpp" with one line in it which is #include then compile it with this g++...
28 Oct 2021 by apetrai
For example, I want int ar[2]{20, 5}; to be stored in a variable double result = 15; What I have tried: for(int i = 0; i
28 Oct 2021 by CPallini
Try also #include #include using namespace std; int main() { array ar{20, 5}; int result{15}; for ( auto x : ar ) result -= x; cout