General C++ Programming - April 2021

by lynn22
How do i write the code for balanced array...URGENT please
An array with an odd number of elements is said to be balanced if all elements (except the middle one) are strictly greater than the value of the middle element...
Apr 30, 2021 at 10:06pm
[13 replies] Last: To be honest, I have no idea. He says it works, though. I have sugge... (by JRManx)
Using CImg to creat 3D object and export to .stl file
I have a 15 year old boy that got a job last summer so that he could buy himself a 3d-printer. He just recently got his second, with conveyor belt. My 12 b...
Apr 30, 2021 at 7:49pm
[1 reply] : Funny, there was just another thread talking about stl files as well. ... (by Ganado)
having trouble with my hw for stl file
* separate compilation Cube.hh Cube.cc Cylinder.hh Cylinder.cc optional: Sphere.hh Sphere.cc Drawing.cc Drawing.hh */ #include "Cube.hh" #include "C...
Apr 30, 2021 at 5:01pm
[6 replies] Last: Forgot to give a reply earlier. I'm kind of just winging this, but you... (by Ganado)
Including/using <regex> will not run on some machines?
I am creating a dll which gets loaded by a game engine. It runs fine on my dev machine, however does not on a secondary machine (it will not bind when the engi...
Apr 30, 2021 at 4:19pm
[2 replies] Last: Unfortunately I don't get to see any error message, as I only have the... (by coldscooter)
thread_local std::vector error
C++ Builder XE4 this code give the error E2461 'TempOptions' requires run-time initialization/finalization static __thread std::vector <int> TempOptions; ...
Apr 30, 2021 at 1:48am
[3 replies] Last: C++ Builder even if it is the latest version (XE4 is from 2013) isn't ... (by deleted account xyzzy)
Greedy algorithm to fill 2d array
Hello, can someone help me with the following problem: Is there a way to write a greedy algorithm that fills a 2d array with numbers? Array array is empty (...
Apr 29, 2021 at 7:26pm
[10 replies] Last: Well here were are, 11 messages into the thread and the OP still won't... (by dhayden)
split string S
How can I split string S into substring S ? Also substring S should set some number a . Should I use strtok to split the string?
Apr 29, 2021 at 5:14pm
[13 replies] Last: cut one segment into two and pay for this a price equal to its length ... (by jonnin)
Converting struct to class? xxx is private within this context
Not sure how to alleviate this issue (see title). I went ahead and was in the process (not finished I assume due to the error) of revamping a program that used ...
Apr 28, 2021 at 8:38pm
[3 replies] Last: If the 0-arg Product constructor must be private, then don't call it. ... (by Ganado)
How to access instance variable value?
I created n objects from the Stock class and assigned a value for the integer instance variable expectancy. This value is different for each object (stock). I w...
Apr 28, 2021 at 7:40pm
[6 replies] Last: vector<Stock> shares( n ); ... ... sort( shares.begin(), shares.end()... (by lastchance)
by CVRIV
Having trouble comparing \r and \n from a text file.
I'm having the weirdest issue. I'm trying to count characters in a text file, while excluding \r and \n. I opened the file in binary mode. If I use Char == ...
Apr 28, 2021 at 2:03pm
[2 replies] Last: Yea.... I figured this out hours ago. I should of deleted this thread ... (by CVRIV)
Nested class/Double-linked list confusion
Hi everyone, we were provided all the following code and told to write the addLongInt() function. We are supposed to be adding numbers using a double-linked lis...
Apr 28, 2021 at 9:25am
[7 replies] Last: There is still a lot I have to learn. Compare your approach to my c... (by seeplus)
Do custom allocator apply just to containers, and how do i apply them to any memory allocation
https://en.cppreference.com/w/cpp/named_req/Allocator I am referring to this ^^^^ kinds of custom of memory allocator (if there is a different kind of alloca...
Apr 27, 2021 at 4:59pm
[6 replies] Last: There's no point in aligning the vector. (by mbozzi)
Log File Wrap Over Failing
Hi All, I'm having an issue with my app at midnight when it's meant to start writing to a new log file. I've created this demo app (spooling a new file every m...
Apr 26, 2021 at 6:07pm
[6 replies] Last: GCC, for instance, will only warn on shadowing if you explicitly enab... (by MikeyBoy)
destructor called after calling constructor
By looking at the example: #include <iostream> int wow=0; class Foo{ int cow = 0; public: Foo(){ std::cout << "Foo +\n"; cow = 0; ++wow; } ...
Apr 26, 2021 at 3:16pm
[7 replies] Last: Okay I already get it. Thanks for your help. (by mjjm1442)
Array of Structures Memory Issue
In my main function, I create an array of structures which stores cache information i.e. dirty bit (bool), valid bit (bool), tag (string), data (string), and ag...
Apr 26, 2021 at 2:40pm
[2 replies] Last: It would help to see the code that's calling the function. How certai... (by MikeyBoy)
should i use static constexpr instead #define () and naming convection (1,2)
in good old c we used to just have #define SOME_GLOB_CONSTANT 5 but now days we also have const int SOME_LOCAL_CONST = 5; class class_name { ... stati...
Apr 26, 2021 at 11:02am
[30 replies] Last: Experimenting is fine. There's lots of existing code that uses macros ... (by seeplus)
for loop question
hi , so this is the question just very confused how to start and end , also please explain me what every line does thank you input 2 output # #**# (What I h...
Apr 26, 2021 at 8:09am
[7 replies] Last: try to break it down into something simpler that is easy to do. This... (by keskiverto)
by RicoJ
"Empty" std::thread is not moved properly?
Here by "empty std::thread" means a std::thread object with "no thread of execution" According to cpp reference, that alose means "a new thread object which do...
Apr 26, 2021 at 4:37am
[3 replies] Last: Hi guys, What is the point of your code? Why are you trying to mov... (by RicoJ)
configuring compilers
I've installed Codeblocks and tried to configure the mingw compiler that I downloaded.. But codeblocks can't find it. Is there any IDE available that doesn'...
Apr 26, 2021 at 12:48am
[2 replies] Last: There is a C::B download that has a C/C++ compiler already set up for ... (by deleted account xyzzy)
std::priority_queue<std::vector> how to reserve space in the internal vector container
I am trying to performance optimize some code and I want to observe the effect of reserving space on queue I have a priority queue (https://en.cppreference.com...
Apr 25, 2021 at 10:33pm
[4 replies] Last: I ended up going with boost::heap::priority_queue which (at least for ... (by Kallinteris Andreas)
April 2021 Pages: 123... 8
  Archived months: [mar2021] [may2021]

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