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...
[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;
[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...
[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...
[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...
[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...
[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...
[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 ...
[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...
[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-...
[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...
[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...
[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...
[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...
[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...
[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() {} }...
[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...
[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...
[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...
[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...
[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.