General C++ Programming - February 2022 (Page 2)

by SSDEEZ
Array of Linked Lists
 
I've made a class defining a list. I know STL has a list function but I went ahead and coded the whole thing. I want to make an array of linked lists and be ...
Feb 21, 2022 at 1:51pm
[7 replies] Last: The code looks to be "over-engineered" -- as well as missing several c... (by deleted account xyzzy)
by frek
packaged_task and future
 
In the code example below, everything "looks" fine, but why do I get a runtime Debug error: abort() has been called , please? #include <iostream> #include ...
Feb 20, 2022 at 4:25am
[2 replies] Last: Thank you. :) I don't know why I'd forgot to call join there! Both jo... (by frek)
by Cplusc
build a solution after cloning from github
 
I cloned the palabos repository using "git clone https://github.com/gladk/palabos.git" into the working directory. Then I tried to build the solution to make in...
Feb 20, 2022 at 3:53am
[2 replies] Last: Thanks for your answer. After many try and errores I used Ubuntu and g... (by Cplusc)
C++ class inheritance, Visual Studio and modules
 
It looks like I found a bug in Visual Studio how it processes module code. Here's some non-module code that compiles and runs fine, a couple of class header fi...
Feb 19, 2022 at 5:42pm
[5 replies] Last: Add the default ctor and comment out the using statement in the modul... (by seeplus)
Rock, Paper, Scissors using enums and functions help!!
 
the requirements for this assignment are to use enums and functions and an option to play again. im pretty confuse on exactly what I am doing wrong. also extrem...
Feb 18, 2022 at 2:01pm
[3 replies] Last: Perhaps something like: #include <iostream> #include <random> #incl... (by seeplus)
by narada
trouble with boundary values for number guessing program
 
The assignment is to write a program that will correctly guess a generated number between 1 and 100. My program can correctly guess any number between 1 and 99....
Feb 18, 2022 at 12:08pm
[2 replies] Last: Small point but if number_generator() was called multiple times (say i... (by seeplus)
How to allow the user to "roll the dice" x times and save those values into a 2D array
 
Hey guys, I am currently working on tweaking a project for my class where we have to allow the user to roll dice (or generate random numbers 1-6) for a total o...
Feb 17, 2022 at 11:44pm
[7 replies] Last: I needed to save the output so that I could plug it into a separate fu... (by NopeNoRoboHere)
by frek
Meta Functions
 
As far as I know, metaprogramming is used in C++ for better performance. I tired to test and figure it out using the example code below: #include <iostream> #...
Feb 17, 2022 at 8:45am
[16 replies] Last: A metaprogram is just a program whose input or output is another compu... (by mbozzi)
by frek
Condition(al) variable
 
What happens in this piece of code? #include <iostream> #include <string> #include <thread> #include <mutex> #include <condition_variable> std::mutex m; std...
Feb 17, 2022 at 5:14am
[11 replies] Last: If by any coincidence, the operating system decides to give the worke... (by helios)
JSonCpp - create a JSON file in C++
 
I have been tasked with creating functionality in C++(running on Linux) to create a JSON file. I have been able to create labels and data:pair for single eleme...
Feb 17, 2022 at 3:31am
[3 replies] Last: nlohmann's json library can be used as a single #include (json.hpp). h... (by Ganado)
C++20, std::format, address of variables and Visual Studio (1,2)
 
Following on from here: http://www.cplusplus.com/forum/lounge/282147/ to https://stackoverflow.com/questions/70712797/is-it-safe-to-bind-an-unsigned-int-to-a-si...
Feb 16, 2022 at 4:26pm
[25 replies] Last: Yes, I know. That is the sole reference I can find, online. (And I t... (by deleted account xyzzy)
Why is my code reading the last Line Twice
 
This program that i created is working, but it is reading the last line twice. Idk what I did wrong. #include <iostream> #include <fstream> #include <stri...
Feb 16, 2022 at 10:16am
[4 replies] Last: If you're been told to use .good() within a loop (bad idea), then you ... (by seeplus)
cassert and templates
 
In Visual Studio, code that compiles outside an assert, does not compile inside an assert. static_cast<_TupleVal<1, int>>(tup2).get() == 2 I am not sure w...
Feb 15, 2022 at 9:38pm
[2 replies] Last: assert is a function-like macro. Macros are expanded during the prepro... (by Peter87)
by SSDEEZ
fully iterating before termination
 
I want this code to keep iterating and check the whole string before terminating the while loop i have setup over this. the problem is that it terminates a...
Feb 15, 2022 at 6:23pm
[11 replies] Last: Take a look at the any_suit_contains_full_run and amend it for your pu... (by Ganado)
by Cplusc
Mpi 32 and 64 platform.
 
I have a vector or vector of type double and a vector of vector of size_t. I'm sending these vectors to different processors. My code is working as I expect in ...
Feb 15, 2022 at 3:10pm
[9 replies] Last: If you are using Visual Studio then you are presumably using the cl.ex... (by lastchance)
Activity using switch case
 
write a program that can compute the grades of the students from pre-mid, midterm, pre-final, final and get the average then identify the average is: below 74....
Feb 15, 2022 at 12:01pm
[11 replies] Last: #include <iostream> #include <initializer_list> int main() { doubl... (by seeplus)
by Adam87
Casting a structure to another
 
Hi, I have a structure that is allocated by malloc My first structure struct TEST_STRUCT { int ID; int x; int i; int y; int z; }; second structure s...
Feb 15, 2022 at 5:28am
[8 replies] Last: My understanding is that you want to reinterpret a chunk of memory th... (by Adam87)
Is it possible to not define the size of a 2d array at the beginning?
 
I want to import coordinates from a csv file and i want to store those data in a 2d array or maybe vector. I dont know which one is more suited for my task. The...
Feb 14, 2022 at 10:20am
[11 replies] Last: #include <iostream> #include <fstream> #include <string> #include <al... (by lastchance)
by frek
Bits manipulation
 
The size of this class is supposed to be 4 bytes: #include <iostream> struct PPN { // R6000 Physical Page Number unsigned int PFN : 22; // Page Frame Num...
Feb 13, 2022 at 5:23pm
[17 replies] Last: @Ganado Cool. Thanks for that :+) ThingsLearnt++; (by TheIdeasMan)
C++20 - import vs. #include
 
I made a somewhat off-hand comment here, http://www.cplusplus.com/forum/general/282156/ , about importing C headers as modules, something the references I am s...
Feb 13, 2022 at 4:27pm
[11 replies] Last: I must modify somewhat my earlier expressed opinion about the "Beginni... (by deleted account xyzzy)
February 2022 Pages: 12345
  Archived months: [jan2022] [mar2022]

This is an archived page. To post a new message, go to the current page.
Registered users can post in this forum.