General C++ Programming - September 2021

I made a cool calculator
 
Hey, I'm currently taking a introductory class for C++, I feel proud that I wrote a calculator program. Is there anything I can do to make my calculator more co...
[7 replies] Last: that is correct, the human has to mentally adjust the input. you get ... (by jonnin)
C++ Help Finding Occurrences of letter d
 
Have to do this and not sure how to do it. Need help with doing it. Instructions: Query the user for the name of a file and then count and report the number...
[4 replies] Last: The only real difference is that I count all the words and those start... (by seeplus)
c++ Temperature bar chart (1,2)
 
Can anyone help me out with this problem This is what I have so far: #include <iostream> #include <string> #include <iomanip> #include <fstream> #inc...
[32 replies] Last: For a vertical chart, perhaps: #include <iostream> #include <string... (by seeplus)
const member fn
 
I got a doubt with const signature from the below code. can anyone help me correct my understanding here? Consider the following class. class ABC {...
[14 replies] Last: Of course. You have valid code when you don't try to make static membe... (by keskiverto)
virtual function performance (1,2)
 
I am seeing a performance issue with virtual functions and it impacts every function call with virtual functions. why am i seeing virtual fns execute slower? Is...
[25 replies] Last: Your closing points seem fine, but I thought I'd add this to the inqui... (by Niccolo)
PURE VIRTUAL FN (1,2)
 
Is below code the right way to overload a pure virtual function? Can overload be only done if I am able to override it? struct I { virtual void func3()...
[31 replies] Last: [quote=denver2020]All I am trying to figure out here is that if its a ... (by MikeyBoy)
Sprcificator %02X
 
Can I get this line in C++? for (i = 0; i < 8; i++) printf("%02X", key );
[3 replies] Last: See my edited post above. (by seeplus)
by jabeh
C++ Coding that create a function that open the contact file using struct, pointers, array, and classes
 
#include <iostream> #include <fstream> #include <string> using namespace std; void printContacts(string user_id , float contact_with , float contact_st...
[6 replies] Last: Very similar to this post here http://www.cplusplus.com/forum/beginner... (by seeplus)
I have a member function of class SparceMatrixStruct which should return a vector.
 
I have a member function of class SparceMatrixStruct which should return a vector. std::vector<size_t>SparceMatrixStruct::col_ind(VecVecIdx_t &refined_node_con...
[1 reply] : > col_ind=object.col_ind_; 1. Make your member variables private, so y... (by salem c)
A5 / 2
 
Where can I find realization of A5 / 2. All I have is below. But as I understand it is A5/1: #include <stdio.h> /* Masks for the three shift registers ...
[1 reply] : https://cryptome.org/gsm-a512.htm It doesn't appear to have an auspic... (by lastchance)
best way to define/declare global data
 
Hi all - I'm maintaining a C program (have added some C++ to it). One source file defines an array of data that was local to that module. I need to expose th...
[2 replies] Last: That is what a header file is for: globals.hpp #ifndef GLOBALS_HPP ... (by Duthomhas)
Can someone explain how the output is what it is?
 
So I have the this code: #include<iostream>​ using namespace std;​ void fun(int x) {​ if(x > 1) {​ cout << --x << " ";​ fun(--x);​ ...
[3 replies] Last: Add print statements and you will see it. #include<iostream> using... (by jonnin)
How do you come to the output?
 
Code: void createList(node*& head)​ {​ for (int i = 5; i < 20; i++)​ {​ bool condition = true;​ for (int j = 2; j <= i / 2; ++j)​ ...
[1 reply] : It gets the prime numbers between 5 and 20 and sequentially prepends t... (by helios)
New to C++ could use some help
 
How do businesses like Amazon™ calculate shipping? The cost of shipping can include the size and weight of an item, where it’s coming from, where it’s goi...
[3 replies] Last: thank you for the link on how to use code tags, sorry about not using ... (by closed account iN72160M)
Question about linked lists
 
Lets say I have a linked list with a struct defined like this. struct LList{ int data; struct LList *NextList; int data2; }; When I allocate memory...
[3 replies] Last: I got nothing on how that could be happening. (by jonnin)
help with cin lines in switch statement
 
Can anyone help and explain to me how to correctly include cin lines? My current code does not have any errors but it won't take any user input. I want to be...
[13 replies] Last: @seeplus Thank you so much! I see what I was missing. Your help is ve... (by closed account 9G8M4G1T)
by Denvor
how do i get my program to run?
 
[10 replies] Last: @Denvor Please do NOT delete your question after getting your answer. ... (by MikeyBoy)
by Qsh222
C++: Find the XOR of a closed interval of the array
 
I've worked out a solution, but it's not efficient. Could someone optimize my solution, using prefix sums. #include <iostream> using namespace std; int ma...
[1 reply] : #include <iostream> using namespace std; int main() { int n, m; ... (by lastchance)
Every 11 years, add certain amount
 
I'm stuck on this part of my homework. Everything else works, except for one function. I need to add 1/7 of an inch for every 11 years over the age of 31. I hon...
[4 replies] Last: fucking life saver. Thanks a lot. (by zer0Cool)
by Qsh222
How to calculate XOR on a given interval of numbers
 
For example, you're given the interval 5 15 17 90. How to calculate the XOR of it?
[4 replies] Last: OP probably meant "sequence", not "interval". (by helios)
September 2021 Pages: 123... 6
  Archived months: [aug2021] [oct2021]

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