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

by PeteDD
class member array duplicating between instances
I have a class which is passed an array (the address of Dallas temperature devices). The data from that array is then placed into a member array. In this exa...
Sep 22, 2022 at 9:10pm
[9 replies] Last: If I were to take a wild guess I'd say you ran afoul of the ODR. https... (by mbozzi)
The same to this in a compile time
How to have this at compile time instead for (int i = 0; i < 41; ++i) interval = 0;
Sep 22, 2022 at 5:50pm
[8 replies] Last: [quote=JLBorges]https://godbolt.org/z/G5oKx8hEj It should be noted th... (by Peter87)
Reading output from valgrind
Hello. I am writing a Monte Carlo simulation engine, and I am experiencing what I believe to be memory leaks in my software. For example, I am running a certain...
Sep 22, 2022 at 8:24am
[5 replies] Last: [quote=lastchance]You have the -g flag set in your compile command: so... (by Peter87)
by helios
Graphs
How do you do general graph structures? I.e. those where any node in the structure can point to any number of nodes in the structure without restriction. The o...
Sep 21, 2022 at 9:42pm
[13 replies] Last: Yes, in my Graph structure, Node might have better named "NodeId".... (by Duthomhas)
integer sum problem
I am trying to solve the problem. Is my logic correct? https://www.chegg.com/homework-help/questions-and-answers/write-function-solution-given-integer-n-retur...
Sep 21, 2022 at 7:00pm
[14 replies] Last: Here's a couple of alternatives. #include <iostream> #include <strin... (by lastchance)
by PeteDD
Link time error - undefined reference
I'm at a loss (once again). In a class method, I am calling a function of the Dallas Temperature library instance which I instantiated as "OneWireBus" in anot...
Sep 20, 2022 at 3:01pm
[11 replies] Last: [quote=doug4]If this template function gets expanded and compiled outs... (by Peter87)
by t im
Mutex Test and Set
I read the code about Mutex test below: static int flag=0; void lock(){ while(TestAndSet(&flag,1)==1); //flag=1; } void unlock(){ flag=0; } And TestA...
Sep 20, 2022 at 2:45pm
[4 replies] Last: Thanks for your reply which makes me figure it out. (by t im)
Stack
Please help me, lets assume that we have an empty stack in the program when executed. When I pop 2 or more it displays the "Stack is empty" a few times. How to ...
Sep 19, 2022 at 1:09pm
[6 replies] Last: In the best tradition - 'We'll leave that as an exercise for the reade... (by seeplus)
Integrating C++ frontend with HTML backend?
Hi guys, I was working on a project recently, the project used Python as the backend and HTML/CSS as the frontend/UI. Python is quite easy to interface with we...
Sep 19, 2022 at 12:40pm
[2 replies] Last: Flask is a small web framework. It's more sophisticated than running ... (by kbw)
vector error
I am trying to solve this in C++. How can I test it? I end up with the below errors while compiling this code. https://www.chegg.com/homework-help/questions-...
Sep 18, 2022 at 5:22pm
[14 replies] Last: @leo2008, FWIW. my approach was: - DRAW the first example; - think abo... (by lastchance)
array of integer problem
Hi all I am trying to solve this problem in C++. Below is what I am trying to do, but has some logical issues. https://www.chegg.com/homework-help/questio...
Sep 18, 2022 at 1:11pm
[3 replies] Last: Thanks everyone for your valuable inputs. (by leo2008)
string issue
I am trying to solve below issue. For example, given K = "Test" and string J as follows: "Jowal Dawn; Pumkin Prejwh; Roger Kim; Joseph Delar; Ivan Shawn; Jimm...
Sep 18, 2022 at 11:53am
[16 replies] Last: 17.1.6 isn't the latest version - 17.3.4 is. Update it! It then compil... (by seeplus)
How to get started with my stack?
So I need to write 2 functions using the standard stack container called evaluateInfix() and infixToPostfix() that will return the result of a math equation but...
Sep 18, 2022 at 2:45am
[13 replies] Last: Ya that's basically the same code I keep seeing. My bad for the confus... (by jetm0t0)
by mbozzi
Can I use std::int8_t* where I want signed char*?
I like to create shorter names for fixed-width integer types: using i32 = std::int32_t; using i64 = std::int64_t; //... But I break the pattern for i8 (a...
Sep 16, 2022 at 1:21pm
[14 replies] Last: Yes I know. I've used C++ since before C++98 - but hands up at the bac... (by seeplus)
File input value as a float?
Hello everyone. I am currently writing a code where it reads a file with information on an item. The file is formatted and each info entry is separated with spa...
Sep 14, 2022 at 8:09pm
[5 replies] Last: Thank you so much. I didn't exactly do the same thing you showed but t... (by BrainD3ad)
by t im
Question on Virtual Function
Just as the code below: class A { public: virtual int func(int i = 1) { std::cout << "class A" << std::endl; return i + 1; } virtual ~A() {} }...
Sep 14, 2022 at 8:03pm
[6 replies] Last: What? #include <iostream> class A { public: virtual void func(i... (by keskiverto)
How to protect dlls?
Hello all , Please, I have two questions, the first : I have a dll file that I inject into a game, is it possible using curl Inside dll? The second How prot...
Sep 14, 2022 at 3:26pm
[7 replies] Last: Thanks kigar , i use cheat engine to inject my dll , but game is cras... (by Hawlong)
30/Distance = force
Hello rubber ducky. I'm writing a game that runs at 60fps. I'm trying to come up with a way to push one object harder if they are closer to the pushing object t...
Sep 14, 2022 at 4:12am
[2 replies] Last: OK. You kind of just rocked my world there. Last time I ran any kind o... (by newbieg)
why is it necessary that this code calls std::forward<>?
Hi, I have this code: int retInt() { return 6; } template<typename T> auto f(T&& val) { using rawVal = std::decay<T>::type; rawVal* tmp = new r...
Sep 14, 2022 at 2:45am
[1 reply] : You don't need to, it does nothing for this example. It would do somet... (by Cubbi)
Implementation of std::forward
Hi, Looking at the definition of std::forward, I found this implementation which does not appear to make sense. It is said that it forwards the argument as a...
Sep 13, 2022 at 11:49pm
[1 reply] : If _Ty is a lvalue reference then _Ty&& is a lvalue reference too.... (by mbozzi)
September 2022 Pages: 1234
  Archived months: [aug2022] [oct2022]

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