Click here to Skip to main content
15,891,204 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 

25 Mar 2019 by #realJSOP
You can use sscanf to make the value a string, and then evaluate the string. Google is your friend.
2 Apr 2019 by #realJSOP
The drive has to support SMART. You can use WMI to detect if the drive supports SMART, and use WMI to pull the data your need. Keep in mind that not all drives support SMART, and even if they do, they may or may not implement all of the standard SMART features. Google is your friend.
10 Oct 2019 by 10xlearner
This is a post about my first open source contribution.
23 Jan 2020 by 10xlearner
Memory Management, more specifically in C++
10 Nov 2018 by 11917640 Member
Int64 localp = RerturnLocalPlayer();
17 May 2014 by _Maxxx_
I need to get the current DateTimeConvert it to a std::string (because it is going to be passed to an encryption function that requires a std::string)I am then going to store the encrypted string in a file.later I will read the string, decode itAnd I want to change it back into a...
20 Oct 2018 by _PitrakSarkar_
I have got myself into a strange issue now. Ill write a really simplified version of the same. class Base { public: virtual int func1()=0; virtual int func2()=0; protected: int n; }; class der1: public Base { //implements the virtual functions of the base and uses the protected data members of...
21 Jul 2020 by abuhmamm
public partial class Form1 : Form { public int xcoordinate = 0; public int ycoordinate = 0; public int ESD_no = 2; public int IntertripESD = 0; public bool MenuClickdone = false; //private...
27 Dec 2017 by aditya tejus
while(i = 0 ) { ------ (expression ) ______(EXPRESSION) . . } What I have tried: READING MORE INFORMATION ABOUT LOOPS
13 Jan 2018 by aditya_parasar
i want to take an input while an infinite loop is running in C++ .but i dont want ot halt my programme .what should i do. What I have tried: plzz help me out!!!!!! i dont want to use getch function . if it is possible then plzz tell me how can i solve this with kbhit function.
31 Mar 2019 by Aek-Tiesto
Dear programmers, I was looking in the internet for an idea on how to create a software or even if there is any existing regarding my issue, but it ended up on this forum Asking for it!! hope I'm in the right place. without further ado let get to my request. I am working in a company where...
31 Mar 2019 by Aek-Tiesto
Thank you Gerry for the solution I'll give it a try. But what if I want to search for Bx that correspond to Ax that I type ???
18 Dec 2015 by Aescleal
There's no reason to use a C style array unless you're using a C++'98 or '03 compiler. Anywhere you'd consider using a built in array (i.e. you want something that's O(1) complexity random accessible) use code>vector if you want it resizable and array otherwise.Most containers use the...
10 Oct 2015 by Afzaal Ahmad Zeeshan
Do not repost the questions. They will not help you get the solution. You can improve your own questions to make them "sensible". If the problem was able to get solved, that easier, I'd provided you with the answer in that post. The solution is in the hands of your teacher, why did he give...
27 Jun 2018 by Afzaal Ahmad Zeeshan
Because a constructor does not work that way in C++, constructors are called once the object is created (or has been created). That means, that the code in the body shall execute after object creation, merely for validation purposes or so. In C++, you can initialize the object that way, so...
7 Nov 2018 by Afzaal Ahmad Zeeshan
If you want to use C# because, then you have to leave all that pointer luxury with the C++. The core concept of C# was to enable you to have a managed environment, where you only had to write the business logic instead of having to manage the low-level memory and hardware as well. C# itself is...
1 Aug 2019 by Afzaal Ahmad Zeeshan
Quote: how to send and receive data from my c++ app to node.js server. If the Node.js process and C++ program are on the same machine, then perhaps an IPC might help you. What you can do is you can use the local sockets and make Node.js listen on a socket—UNIX Sockets for instance. Can node.js...
4 Aug 2020 by Afzaal Ahmad Zeeshan
Quote: A 'delete student5' statement was not added since student5 was passed to a method or constructor. Handle memory management manually. That is one of the areas where C++ and Java differ; memory management. What this comment is telling you is...
21 Aug 2021 by Afzaal Ahmad Zeeshan
It says right in the comment, //compiler generated initialization function What you see (and many other similar gibberish names of the functions with their parameters) are the output of the compiler. For C++, you can use the g++ to output the...
23 Feb 2017 by ahmed91za
as a starter myself i spent will over 2 weeks learning C++ from various sources such as books (but sometimes the volume of pages like 600+ scare me) i consider myself a beginner even though i have good knowledge in c++ basics i still struggle with class inheritance , error handling, pointers and...
17 Oct 2018 by Aishwarya Prakash Verma
def readinput(): n = int(input()) # Length for j in range(n): nextnum = int(input()) # Read each value insequence.append(nextnum) best.append(0) # Initialize best[k] for each position return def solve(): for j in range(len(insequence)): # Collect best[k] for...
14 Oct 2011 by Ajay Mohan
I am a beginner to this c++ language,a problem arised while del() function was carried out in my program which follows as:#include#include#include#include#include#include#include#includeclass...
16 Jan 2013 by Ajay Vijayvargiya
Covering the nitty-gritties of C++ templates.
16 Jul 2018 by Ajcek84
Have you considered paging or infinite scrolling? Items may be created/retrieved in a different thread but updating a control always blocks UI thread unless the control supports some kind of virtualization. The best approach is add items by parts (for example 200 items at a time) but you should...
1 Jul 2016 by ajitdstar4u
btsSubscription = common::lim::subscribeCreate(lim_,{ lim::MoLnbts::className },[this](const lim::DistName& dn) { handle(dn); });What I have tried:i m trying understand this code of line.I find that, this one is a lambda function.
29 Nov 2010 by Alain Rist
With a helper CharMap class using VC2010 C++0x implementation
15 Feb 2016 by Alasdair Craig
Common ways that code gets duplicated, and techniques for avoiding or refactoring the duplication
19 Jan 2018 by Alex Schunk
Why are you using char arrays? COM is capable of using strings.
2 Sep 2011 by Alexander Bessonov
A simple high-level IPC library with ability to use native C++ interfaces.
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); }
30 Mar 2021 by AlexeyAB
Smart pointer that makes any object thread-safe for any operations, with the performance equal to that of optimized lock-free containers
9 Jan 2018 by Ali Al-Masry
Hey guys i am new to c++ and i`m trying to load .xml file it`s located at debug folder and "//Data/Filename.xml" how i can read it using c++ ? What I have tried: i tried using ifstream fs("//Data/Filename.xml"); but the file is always not found even if i moved it to debug folder directly ...
19 Jan 2018 by Ali Al-Masry
at first i would like to mention that i am new to c++. i am working on a c++ core system server side application(unmanaged), C# auth system server side application and C# client side application. i am using a simple 2 functions to encrypt/decrypt packets between server`s and client Encrypt and...
15 Jul 2020 by aman nimje
Asha and Amar are playing SpaceKings a video game. It is a two-player game where the second player is the helper. Asha needs your help maximizing her gold while playing her favorite game. Both are facing N aliens. Asha and Amar are both at a...
17 Oct 2015 by amin.j
I would like to ask how is it possible to do typecasting and then dereferencing in C++, I mean with C++ code not C. Here, it is a part of code which simply type casted in C, how can do that in C++?bool equals_double(const void* elem1, const void* elem2){ if (*(int*)elem1 ==...
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...
22 Oct 2015 by amin.j
is there any way to sketch a line between two vertices in c++? I mean, for example, between the (0,0) and (4,3) in 2D plane with characters. (without using c library functions)
13 Jan 2018 by ANAGHA S GOURI
I did a `MATLAB` code and it had to perform B2=abs(B2/max(B2)); where `B2` is an `n x m` matrix . What should be the equivalent `C++` code using Eigen library? Please help. On modifying my code //problem #include #include #include
16 Jan 2012 by And Baxter
In the case that you need to store and pass lambdas around but can't use std::function, here's an alternative.
12 Feb 2012 by Andreas Gieriet
HTML page with all syntax/grammar productions of C++98/C++11
20 May 2013 by Andreas Gieriet
I regard using char* str = new char[sz]; as deprecated/anachronistic.If you do string handling, try using std::string str = ...; or if you work on raw memory try using std::vector mem;. Both are smart enough to handle the dynamic memory in a decent way, i.e. you do not have to care about...
17 Oct 2015 by Andreas Gieriet
How about Google?E.g. see http://www.cplusplus.com/doc/tutorial/typecasting/[^].RegardsAndi
17 Dec 2015 by Andreas Gieriet
See the definition of pop_back().E.g. from http://www.cplusplus.com/reference/vector/vector/pop_back/[^]. It says that pop_back() from an empty collection is undefined behavior, which includes "crashing".[EDIT]Your logic is broken: while(!human.empty() || !zombie.empty()) ... is also...
2 Oct 2011 by André Kraak
Read this Wiki[^] to understand the magic square and try it yourself.You can comeback here and post a question about specific problems you are having with your implementation to solve the puzzle.
7 Oct 2011 by André Kraak
You are using a temporary variable in the statement fileop.pFrom = (string("c:\\mapper\\").append(string(iter->cFileName)).c_str()); which will cause problems with the use of the SHFILEOPSTRUCT structure later on.The temporary variable is destroyed after the ; and the memory can be reused and...
4 Oct 2011 by anktrive
Hi, I am new to JNI and I have been trying to write a simple program to call Java code from C++. I am facing problem in creating the JavaVM from C and am getting the Linker error. I have tried changing the GNU library files in dev C++ (I am using Dev c++ compiler) but no luck so far....
25 Mar 2014 by Anna Koneva
An article about interoperation issues in mixed C/C++/Objective-C development
12 May 2014 by Anna Koneva
An article about interoperation issues in mixed C/C++/Objective-C development
6 Apr 2018 by Anonygeeker
Hi, I want to write a c++ program including: 1. virtual function 2.static member function 3.assignment operator 4.copy constructor 5.function overloading how to approach this? What I have tried: I just wrote how basically everything is implemented, but that was wrong
6 Apr 2018 by Anonygeeker
What I have tried is : #include using namespace std; class base{ int a,b; public: base(){ cout
13 Apr 2015 by Anton Chibisov
This tutorial showcases how to implement C++ delegates which are capable of being bound to methods and functions having arbitrary signature, i.e., any number and type of parameters and return value.
13 Oct 2021 by apetrai
I'm a 13 year old who's just tring to experiment with things in C++. I declared a vector for storing the contents of a file and a pointer with dynamically allocated memmory. With this, I could perhaps make some sort of an local account database....
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
7 Dec 2015 by Are Riff
How do I create copy constructor in derived class. Both base class and derived class has it's own unique members. The base class itself has its own copy constructor defined. The workaround I know is to create two separate classes.
8 Dec 2015 by Are Riff
Solution found.class Warrior : public Human {private: int _armor; int _defense;public: Warrior(); Warrior (const int &id, const int &h, const int &a, const int &def): _armor(a), Human(id,h) {} Warrior (const Warrior &rhs): Human (rhs), //...
8 Dec 2015 by Are Riff
Why this operator++ return a warning?Human& Human::operator++(int){ Human temp(*this); operator++(); return temp; // warning here.}The warning is:Reference to stack memory associated with local variable 'temp' returned.There was no problem with the result...
12 Dec 2015 by Are Riff
#include #include #include using std::cout;using std::cin;using std::endl;using std::ostream;// Random value generator functiondouble randomize(const double &minVal, const double &maxVal){ std::random_device rd; std::mt19937...
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 =...
5 Apr 2017 by Are Riff
I am learning about smart pointers.class Elf {private: int _health = 0;public: Elf(const int &health){_health = health;} int getHealth(){return _health}};What is the different between these two?First case:vector> elves;for (auto i = 0; i
17 Dec 2015 by Are Riff
The code is here. It's almost 1000 lines. The first 800 lines are just class and declaration. The problem start at around line 910+.http://cpp.sh/7qrh[^]I have this code here, it compiles ok. But it crashes when executing pop_back() on the vector in line 919.It crashes and show the...
17 Dec 2015 by Are Riff
I've read this article: https://isocpp.org/wiki/faq/containers#arrays-are-evil[^]Should I almost always use C++ containers overs standard C arrays?Another question, as a novice, I want ask whether containers such as vector always put their elements on the heap? thus there's no need for new...
19 Feb 2016 by Are Riff
This is a continuation from my previous question Hall of Fame[^]By following the advice from Richard MacCutchan[^], I tried using vector in my implementation of Hall Of Fame which has name and score.The name should not have duplicate and score should be sorted. However here I'm...
6 May 2020 by Arthur V. Ratz
In this article, I’d like to introduce the modern code in C++11, implementing the parallel three-way quicksort, which is asymptotically faster and more efficient than the famous heapsort and mergesort algorithms.
9 Dec 2016 by Arthur V. Ratz
In this article, we'll demonstrate an approach the allows to increase the performance (up to 600%) of the code that implements the conventional distribution counting algorithm (DCA) using NVIDIA CUDA 8.0 Runtime API
7 May 2020 by Arthur V. Ratz
In this article I will thoroughly discuss about the several aspects of using the revolutionary new Intel® oneAPI HPC Toolkit to deliver a modern code that implements a parallel “stable” sort
30 Dec 2018 by Arthur V. Ratz
SVD in C++11 explained with an example
1 Feb 2017 by Arun Maiya
After seeing your comments I understand that you are talking about clearing the console before printing the output. Pass clear screen command to your console.case 2:system("cls");c = subt(a, b);cout
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.
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...
31 Oct 2015 by Assam ALzookery
Use the switch and do while statements to write a program that displays the following menu:---------------------------- Menu -------------------------1.Option 1 2.Option 2 3.Option 3 4.Option 4 5.Help6.Quit----------------------------------------------------------- Please...
1 Nov 2015 by Assam ALzookery
#include using namespace std;int main() { int Number; int Menu; cout
1 Nov 2015 by Assam ALzookery
Using for statement, write a program that prompts the user for a positive integer n then display all positive even numbers less than n then display their sums and product.Please tell me how to display even number #include using namespace std;int main() { int...
1 Nov 2015 by Assam ALzookery
#include using namespace std;int main() { int n; int sum=0; int product = 1; int countNumber = 0; cout > n; for (countNumber = 2; n>countNumber; countNumber += 2) // everything in the for(;;)...
4 Nov 2015 by Assam ALzookery
I have already created a file called ( student.txt) and i put the following information inside the file Will Smith 99 Sarah Johnson 100 Tim Howard 70 Francesco Totti 95 Michael Jackson 92I want to ask the user to enter the file name,once they enter the file name, I want to...
8 Nov 2015 by Assam ALzookery
Can someone please help me to answer the following questions with explanation? How many functions are defined in this program, besides the main() functions? Give the prototype of each function? Give the arguments of each function?#include #include using...
26 Aug 2013 by Aswin Waiba
A simple trick to understand isconst char *ptr = &someVariable;see *ptr, which as normal usage signifies data. So data is constant. i.e you have a pointer pointing to a constant data. You cannot do something like char var = 'a';const char *ptr = &var;*ptr='c';//not...
30 Dec 2014 by Babu_Abdulsalam
Various features supporting Concurrency in C++11
17 Dec 2015 by barneyman
horses for courses ... generally tho, stl containers are better (IMO) *as long as you choose the right one for the right job* i.e. understand the difference in behaviour between a deque and a vectoryes - they heapify - if you're going to use them for classes, understand the copy constructor
7 Jan 2016 by barneyman
the rename is simply right click on the rc file in the visual studio project explorer, and choose renamethe dialog caption rename is trickier ... it's either statically defined in the rc file itself (use the VS resource view to examine it) or it's set by code, probably in OnInitDialog
22 Oct 2018 by Bartje_
I think it could be one of two things: Use the Application.Run method to start the form (More info: Application.Run Method (System.Windows.Forms) | Microsoft Docs ) Or try adding the STAThread attribute to your EntryPoint method (More info: STAThreadAttribute ) According to the documentation...
27 Aug 2014 by Bartlomiej Filipek
Several issues related to smart pointers that are worth knowing.
14 Oct 2014 by Bartlomiej Filipek
Simple introduction to std::future and std::async and why they can be useful.
27 Apr 2014 by Bartlomiej Filipek
This book is a must-have resource for any C++ developer!
2 Jun 2014 by Bartlomiej Filipek
How memory access patterns can influence performance of your code
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.
16 Dec 2014 by Bartlomiej Filipek
Several examples of beautiful code made up of algorithms from the C++ standard library. Heavily uses modern C++.
22 Feb 2015 by Bartlomiej Filipek
My short summary for non static data members initialization from modern C++. A very useful feature.
29 Feb 2016 by Bartlomiej Filipek
In the article I cover SFINAE, a quite complex paradigm from C++ template programming area. What is this thing? Where can you use it? Let's also look how C++14/17 can help in writing such expressions.
30 Jan 2018 by Bartlomiej Filipek
It appears that in some cases memory allocated for the object controlled by smart_ptr might not be released until all weak pointers are also ‘dead’... let's see why
13 Oct 2021 by BernardIE5317
Greetings Kind Regards Merely declare your base class counter static - Cheerio
12 Jun 2018 by BerthaDusStuf
I am reading a book called jumping into C++ by Alex Allain and he has introduced maps with lines of code like: map name_to_email; name_to_email[ "Alex Allain" ] = "webmaster@cprogramming.com"; cout
14 Jun 2018 by BerthaDusStuf
I am reading jumping into C++ currently but I have a computing project for school where I will need to program in 3D so I want to learn to program in 3D ASAP. I dont have any experience in 2D programming and would like to skip that if possible and then return to it after I have completed my...
28 Jun 2018 by BerthaDusStuf
In the book I am reading "jumping into C++" there is some stuff I dont understand. Here is the code: class ChessBoard { public: ChessBoard (); string getMove (); ChessPiece getPiece (int x, int y); void makeMove (int from_x, int from_y, int to_x, int to_y); private: PlayerColor _board[ 8 ][ 8...
4 Jul 2018 by BerthaDusStuf
I am reading a book and it includes code for an assignment operator and I'm pretty sure it is incorrect but I also think maybe I am just wrong because it is unlikely the book will make a mistake. Here is the code: LinkedList& LinkedList::operator= (const LinkedList& other) { // make sure we...
11 Jul 2018 by BerthaDusStuf
I have around 1 month to learn OpenGL for programming in 3D. I have knowledge of C++ already, I have an alright ability to use classes. I am trying to make a program that will be an online 1v1 sniper game where you have two players on a simple map where the players and the map are built using...
12 Nov 2018 by BerthaDusStuf
Stack over flow question: Title: Why cant I see my texture load Explanation: I have been trying to texture a cube I have created and I am not able to see the textures. I can just see a blank cube rendering. I have looked at the code to see if there is anything wrong with it however I don't see...
29 Oct 2015 by bijaynayak
Hi Coders,In interview i have asked a question write a code in c++ which will list out all the member functions of that class.Thanks,Bijay
31 Oct 2015 by bijaynayak
Hi Coder,I am trying to explore in c++11.but while trying to compile the following snap of code getting lot of error,i know missed the c++ 11 set up.How to compile the following code.int main(){ enum class Color { RED, BLUE }; enum class Fruit ...
15 Nov 2015 by bijaynayak
Hi Coders,I want to know where we have to use dynamic_cast in the real time scenario....Yes i under stand that this is RTTI but want to know the exact scenario OK here we have to use the dynamic_cast Don't have other options
28 Nov 2015 by bijaynayak
while compiling this cpp file getting the compilation error.class A final{public: A() { cout