General C++ Programming - February 2021

by VoB
Why is this trivial code leaking memory?
 
Hi everyone, I'm trying to figure out why the following snippet #include <vector> int main(){ std::vector<int>* ptv = new std::vector<int>{}; // ...
[13 replies] Last: Generally, you only need worry about leaks in code that can be tracked... (by salem c)
how to find out what people celebrated their birthday this year
 
how to find out what people celebrated their birthday this year, if we have the current month and day, and we have the birth day, month and year of the person?
[1 reply] : Read a pair of y/m/d into variables Apply https://www.cplusplus.com/re... (by salem c)
by MA2121
Need Assistance fixing this program
 
Write a program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: *...
[2 replies] Last: When posting, please use code tags so that the code is readable! #i... (by seeplus)
Value keeps resetting once I go back to the menu
 
I'm having a hard time thinking how can I change my variable after it executes. #include "Register.h" #include <iostream> #include <fstream> #include <st...
[12 replies] Last: Based upon file data, consider as a start: #include <iostream> #inc... (by seeplus)
"Unresolved external symbol" even when the linker can find the function body
 
Hello, I'm getting an extremely strange error, I have utility functions declared in a header file and the function bodies in Utils.cpp. I have defined function ...
[2 replies] Last: I found the issue and fixed it, My issue was that my Utils.cpp file ha... (by icegolem123)
member function already defined or declared in variadic template
 
I am getting this error: 'Group<std::string &>::Group(T1)': member function already defined or declared from this code template<typename ... T...
[2 replies] Last: Thanks @mbozzi! (by JUANDENT)
trying to finalize this assignment
 
Trying to finalize this assignment, I had gotten help but I was only given hints regarding where I should change something from lines 24-29. I did some changes ...
[2 replies] Last: the assignment details are here, sorry forgot to post it: https://past... (by juicypwner)
C++ programming challenge
 
Have gotten this far but am lost could use some guidance Am writing to get an output of: My date is May 25, 2002 or any date that is to be inputted by the...
[12 replies] Last: Thanks for clarifying, @ Furry Guy ! Although, I was told that it i... (by JRManx)
by YViera
Is there an easier way of sorting this?
 
Hello, I am trying to figure out an easier way of sorting based on frequency to be specific: "Sort the alphabet in decreasing order based on the frequency. If t...
[3 replies] Last: #include <iostream> #include <string> #include <map> #include <set> u... (by lastchance)
Vector and Template
 
Hello everyone. I am creating a lib. In this lib I need to create a template where the T object (class) will be added inside the vector. I have questions about ...
[1 reply] : As the code is very large, the main function of the code above is in t... (by joaoelson)
by YViera
Getting expression must have class type error as well as invalid types error. (Multithreading)
 
Hello, I'm getting an error with my program when using maps with pointers. For context, I'm trying to calculate the frequency of each character in a string that...
[1 reply] : #include <iostream> #include <string> #include <map> using namespace... (by dutch)
by soon45
I am having trouble for this C++ Payroll
 
I am supposed to take advantage of the arrays by breaking the programs into separate types of units. Every unit needs to have a separate loop. I am also not sup...
[14 replies] Last: Hello soon45, agent max is correct I only showed the input part and... (by Handy Andy)
one or more multiply defined symbols found when using catch2
 
Hi, I am #including catch.hpp in several source files of a project but I get one or more multiply defined symbols found What can be going on? Ma...
[3 replies] Last: Catch2 is a header only library where only one of the source files mus... (by JUANDENT)
by JRManx
HTML table with C++
 
Hi! I'm trying to use C++ to print HTML code for a table to a file, then open it for viewing (in a web browser or something that can read HTML). Here's what I'...
[11 replies] Last: Thanks @thmm! It was just an experiment really, but that video was a b... (by JRManx)
by VoB
Fully qualified name and type alias as return value
 
I have an header file, for which I want to write the definition of the function not right after the declaration. The only problem is that the return type of suc...
[5 replies] Last: I've just tried to compile their code (with clang 12.0), and I always ... (by VoB)
C++ programming challenge
 
7. Most Fuel Efficient Car Three cars drive a 500 mile route. Write a program that inputs the car make and the number of gallons of fuel used by each car. A...
[4 replies] Last: thank you all for the help! i really appreciate it (by jtherudy96)
by SSDEEZ
Padding for BMP files with Dynamic Memory
 
So the goal of this program is to invert a picture's pixels in a BMP format. I'm not really understanding how the padding part of the code works as far as fsee...
[5 replies] Last: The 'if' part needs the same test as the calculation if ((info1... (by dutch)
setprecision not working
 
Write your question here. #include <iostream> #include <iomanip> using namespace std; int main() { int carbs; int fat; int pro...
[9 replies] Last: Eye-opening! Thanks, @Furry Guy! (by JRManx)
std::unique_ptr::get vs std::shared_ptr
 
Hi. When you use unique_ptr, think about you need the pointer in other space. In other space, the pointer used as read only. So you can use unique_ptr::get...
[5 replies] Last: I thought I'd point out something about the concept of shared ownershi... (by Niccolo)
by kitfox
It would be nice if C++ had better support for smart pointers
 
This is more of a gripe than a question, but I've been getting into using smart pointers in C++. While they provide a lot of advantages over raw pointers, they...
[11 replies] Last: As mbozzi points out it can be difficult to speak only in generalities... (by Niccolo)
February 2021 Pages: 123... 6
  Archived months: [jan2021] [mar2021]

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