General C++ Programming - July 2020

by bibo
Pass member function as a argument
 
typedef bool compF(int, int); typedef priority_queue<int, vector<int>, function<bool(int,int)>> mypq_type; class Node { public: bool end=false; ...
[2 replies] Last: minimum (but far from best) fix is probably to bind your member compar... (by Cubbi)
by bibo
Need of declaring a data member directly inside constructor
 
typedef priority_queue<int, vector<int>, function<bool(int,int)>> mypq_type; class Node { public: bool end=false; unordered_map<char,int> next; ...
[1 reply] : to call the constructor of base class and member variables use the ini... (by ne555)
Deleted constructor acts strangely
 
I have the following class: class Foo { public: int blablabla; Foo() = delete; Foo(int x) : blablabla(x) {}; ~Foo() {}; }; As you see, I have deleted...
[5 replies] Last: I understood finally. Didn't know I could declare a function inside an... (by PSYCHAMERON)
Passing member function as a parameter...
 
I want to pass(from one class to another) a member function as a parameter and then for that member function to be called in a separate thread. This seems to...
[2 replies] Last: Thank you very much, was pulling my hair out with this. (by LearnsMore)
Read and write REAL scalars from and to file
 
I need to read and write REAL acalars from and to file. Please advise how to correct the following blocks of code. 'Short' and 'REAL' are mandated by the mode...
[3 replies] Last: are you writing them as text? You may want more digits, eg %1.15f as... (by jonnin)
Character placement in a grid
 
Hello, how can I place characters other than the @ in the grid without the grid marking every position of the @? I don't want to keep the @ on every position I ...
[12 replies] Last: Hello the two separate functions work as I want. But I have to be able... (by oneidacharisse)
CppCast: TensorFlow
 
Rob and Jason are joined by Andrew Selle from Google. They first discuss Ranges support being added to Visual Studio, and Compiler Explorer’s support for usin...
[1 reply] : Don't bother with this trash. The broadcast sounds like unintelligible... (by againtry)
Problem with AABB Collision Resolution
 
AABB Collision Detection is easy. You simply set up the sides of a square or rectangle, and see if they overlap with the sides of another square or rectangle...
[4 replies] Last: Thank you doug4, Ganado, and jonnin for all of that information. doug... (by AspiringProgrammer85)
Memory alignment (1,2)
 
So I know that memory alignment to a 1 byte boundary may be used in special circumstances lets say you need to read or write data to conform with network protoc...
[23 replies] Last: so it could be padding, but it could be a short ( 2 bytes ) or 2(char... (by helios)
Mutiple or conditions
 
Hi, I have three conditions and want to go to the top of loop if any of these conditions is true. So, I have written the following code, but it only works if...
[18 replies] Last: Ah, I thought you were referring to my 2 page calculator code which wo... (by jonnin)
reading input files
 
Hello, suppose i have a test.txt file that contains 1 0 3 2 1 4 3 2 5 and i want this to be taken into my main file which reads the first column and stor...
[9 replies] Last: #include <iostream> #include <fstream> /* test.txt 1 0 3 2 1 4 ... (by againtry)
Check out Yahtzee
 
Hi all. I had the source code up a few days ago, but took it down when I decided to improve the looks of the game. Hopefully, some of you will D/L the code, com...
[6 replies] Last: Hi all. I was hoping to be informed if there were improvements to the ... (by whitenite1)
by RicoJ
Template Function vs Function Template
 
if a function template is template <typename T> void f(T) { puts("master"); } and a template function is void f(boost::optional<bool>) { puts("optiona...
[3 replies] Last: Nice, I searched around and did not find anything about " template fun... (by RicoJ)
writing to a file ( file formats)
 
I'm trying to make a simple steganography like program that will change every 50th byte of an image to the value 0xff but I'm having no success, I'm not sure...
[8 replies] Last: I always used uncompressed tga, which is similar to above but in stand... (by jonnin)
Passing std::function by value VS by reference
 
I have been thinking about this for some days and haven't been able to get an answer for this. What is the effect of passing std::function by value VS by refere...
[4 replies] Last: a nitpick, "// # PASS LAMBDA BY" is misleading; those functions are ta... (by Cubbi)
custom cmd line program in c++
 
Hi I am using zbar for barcode scanning. and I want to execute a commaand in command prompt provided by z bar in a c++ console application I need guidance I a...
[2 replies] Last: windows and dos both support pipes and files too. so system("program... (by jonnin)
Correcting a grid map display
 
Been trying to solve this for hours but has been futile. Below is a reproducible code #include <stdio.h> #include <iomanip> #include <string> ...
[7 replies] Last: Newbie812, your logic is inside out. You have generic loops and the w... (by dhayden)
by thmm
Safe to ignore this warnings ?
 
I was playing around with modules in VS 2017 CE and got this warnings. Are they safe to ignore ? Error C4996 'std::uncaught_exception': warning STL4006: std:...
[5 replies] Last: @Furry Guy, yes I set the project options. The code actually runs fin... (by thmm)
by mehat
Double derivative by c++
 
//How to find the value of 2nd derivative. #include <iostream> #include <cmath> using namespace std; int main(){ int po,p,mul; int x1,x2,x3,diff=0,x,n=1; cout<<...
[4 replies] Last: And as an alternative to <vector>'s and subject to tidy-up terms can b... (by againtry)
template template : no matching function for call
 
this code compile fine in the old compiler (RAD studio XE4) in version 10.3 i get this error: error: no matching function for call to 'VectorMove' note: candi...
[5 replies] Last: Thanks I think you're right. (by Ganado)
July 2020 Pages: 1234
  Archived months: [jun2020] [aug2020]

This is an archived page. To post a new message, go to the current page.