Category "c++"

Is an "if(...) return ...;" without "else" considered good style? [closed]

This code: if( someCondition ) return doSomething(); return doSomethingElse(); versus this code: if( someCondition ) return doSom

Embedding resources in executable using GCC

I'm looking for a way to easily embed any external binary data in a C/C++ application compiled by GCC. A good example of what I'd like to do is handling shader

Setting mouse position?

Well I'm working on a small program and I'm trying to set the position of the window's mouse to it's center every time it moves. Thing is I have no idea how to

Performance of Win32 memory mapped files vs. CRT fopen/fread

I need to read (scan) a file sequentially and process its content. File size can be anything from very small (some KB) to very large (some GB). I tried two tec

Set the digits after decimal point

I have a float number for example 12.12123 Is there a function which would display only number with 2 digits after decimal point 12.12 ? Here is the code: y1

I'm having trouble putting who wins in my game

So everything in my code works so far, but I don't know why the checkWinner function doesn't work. In my Bool checkWinner function, I used bool. When I call th

convert an int to QByteArray in Qt

I'm trying to convert an int to QByteArray. I'm using this method QByteArray::number(m_vman); is it correct? I'm trying to use the number() for getting an int t

invalid fastbin entry (free)

I am trying to find the cause for: *** glibc detected *** ...: invalid fastbin entry (free): 0x00007fc384ced120 *** The program dumped core, so I was able to

Excel RTD (Real Time Data) client other than Excel?

I have been looking all over, and couldn't find any example for an RTD CLIENT (many RTD server samples, though). My goal is to 'pull' data from an RTD server i

clang-format for Eigen matrix initialization

To inialize for example Eigen::Matrix3i we can use syntax: Eigen::Matrix3i T; T << 1, 0, 0, 0, 2, 0, 0, 0, 3; However, when using clang-forma

I failed to compile C++ code on Visual Studio Code

I'm using "glut" library and trying to compile code by gcc compiler, but it gives undesireble result. When I try to build command (Ctrl+Shift+B) on Visual Studi

Exact difference between rvalue and lvalue

While I was reading http://thbecker.net/articles/rvalue_references/section_01.html, I got following snippiest. // lvalues: // int i = 42; i = 43; // ok, i is an

How to put what the user picks for the row and column in the board

So my question is how do I put what the user enters, for example, they put row : 1 and column: 2 in my board that I made. I'm working on this in the void player

Outputting Date and Time in C++ using std::chrono

I have been upgrading some old code and have been trying to update to c++11 where possible. The following code is how I used to display the time and date in my

Unreal: How to access image in MediaTexture with C++?

I'm currently using unreal read from video and cameras. I got a Media Player and Media Texture alongside with it. I'm aware that It is possible to read pixels f

How to colour vertices as a grid (like wireframe mode) using shaders?

I've created a plane with six vertices per square that form a terrain. I colour each vertex using the terrain height value in the pixel shader. I'm looking f

return type of operator+= while overloading

I have gone through some examples in the internet for operator overloading where the return type of operator+= is T&. Since we can't chain += like T a = b =

Optimizing Fixed-Point Sqrt

I made what I think is a good fixed-point square root algorithm: template<int64_t M, int64_t P> typename enable_if<M + P == 32, FixedPoint<M, P>

How to design a utility class?

But I don't know if I should go for static methods, just a header, a class, or something else? What would be best practice? But, I don't want to have an instan

Use of incomplete types in templates

Is it legal to use an incomplete type in a template if the type is complete when the template is instantiated? As below #include <iostream> struct bar;