General C++ Programming - October 2019 (Page 4)

Non-member class functions not working
 
I have a question that says I have a class called Money and the file money.txt has 2 values in each line, one for dollars and one for cents, separated by a spac...
[4 replies] Last: you typically have a get and a set. cout >> thing.get(); cin >> tmp;... (by jonnin)
Analyzing the Code of ROOT, Scientific Data Analysis Framework
 
ROOT is a modular scientific software toolkit. It provides all the functionalities needed to deal with big data processing, statistical analysis, visualisation ...
[no replies]
Converting InFix to PostFix with Linked Stacks
 
#include <iostream> // <<, >>, cout, cin #include <string> // string, ==, find, npos #include <cassert> // assert() #include <ccty...
[1 reply] : 1. Please use the code formatting tags to format your code. It's not ... (by kbw)
cannot get program to end if user enters quit
 
I cant get the program to terminate if the the user enters exit. Not sure what I did wrong. Thanks int main() { string input; int operand1, operand2;...
[4 replies] Last: A couple of things: 1. PLEASE learn to use code tags, it makes readin... (by deleted account xyzzy)
basic_string::_S_create
 
am trying to run mu program but i got the following error message "terminate called after throwing an instance of 'std::length_error' ...
[4 replies] Last: am trying to run mu program but i got the following error message "te... (by jlb)
Is there better way to increment the count every 10, 100, 1000, ...?
 
The problem I faced with this idea was when I was supposed to count the length of some string. If I get aaa...a (a times 10), this string compressor makes it i...
[7 replies] Last: Use the standard solution: escape sequences. For instance, with the c... (by JLBorges)
Can binary search fail if low = mid instead of mid + 1?
 
I am trying to understand how binary search works. The basic code, for anyone who doesn't know, is as follows: while (l <= r) { int m = l + (r...
[2 replies] Last: has nothing with either one instead it depends on what are contents of... (by marhuum)
Want to create padded 2 dimensional vector in c++ style
 
I was trying to create padded 2 dimensional vector in c++ style, like using copy or copy_n function in algorithms library, couldn't think of proper code for it....
[2 replies] Last: #include <iostream> #include <string> #include <vector> using namespa... (by lastchance)
if statement with multiple conditions
 
I'm trying to create a program that outputs your zodiac animal based on the year you're born in. I've tried a few things but no matter what year I enter, the ou...
[2 replies] Last: // if (bornYear==1924||1936||1948||1960||1972||1984||1996||2008) sho... (by JLBorges)
by dmo
how to implement the playGame() function so it doesnt break the working code
 
#include <iostream> #include <string> #include <fstream> #include <stdlib.h> #include <time.h> #include <algorithm> using namespace std; /** * Fun...
[11 replies] Last: thanks homie but i figured it out. In the future, I'll be more specifi... (by dmo)
Understanding this code of Binary Search Tree Implementation through Array
 
Oh My, sorry... Got it wrong totally.. Please delete this
[3 replies] Last: Please don't go deleting your question after you've received an answer... (by MikeyBoy)
Election Security
 
Rob and Jason are joined by Patricia Aas from TurtleSec. They first discuss blog posts on module linkage and Visual Studio integration of clang tidy. Patricia t...
[no replies]
Use arrray and for/while loop to create a quiz game
 
Thank you joinnin and Thomas for your reply! I almost had a panic attack this morning as this homework due tomorrow. After revised some of bad syntax, I am stil...
[5 replies] Last: Fix 3 things first and then re-post in code tags. (1) Initialisation ... (by lastchance)
string parsing
 
i was learning string parsing using c++. i came across a problem where there are many delimiters and specific string needs to be selected from the given succes...
[4 replies] Last: @Duthomas thank you for your help , those stl functions were very he... (by cplusplus121)
HELP {PROGRAM}
 
Hello everyone . So i tried to make a program that allow the user to select if he wants to add subtract multiply or devide . This is the program : #include <st...
[1 reply] : [quote=JOHN2172000]Its working well Well, that's a matter of opinion. ... (by lastchance)
How to correctly initialize instance of a class that has a template?
 
I am creating my own implementation of a List ADT and I am really confused as to a linker error that I am getting. When I compile with g++ -std=c++11 prob...
[14 replies] Last: You are welcome. Template techniques are sometimes confusing, please b... (by Mitsuru)
Why getting a value from a function using auto&& seems to produce a temporary value
 
I have the following code: int&& getInt() { return 4; } int& getLvalueInt() { int r = 5; return r; } int main() { auto&& ex = getInt();...
[5 replies] Last: An lvalue reference won't bind to an rvalue, which is a problem in thi... (by mbozzi)
Do I need a destructor if I allocate memory in a local environment?
 
Say I have a function: void createNode() { Node *someNode = new Node; } When the function terminates, does that local Node variable memory be...
[2 replies] Last: Okay. So it would be better to use dynamic allocation if you want the ... (by vaderboi)
namespace {…} without any namespace name
 
What actually is meant by namespace {…} without any namespace name which is sometimes seen in C++?
[1 reply] : Unnamed namespace: https://en.cppreference.com/w/cpp/language/namespac... (by JLBorges)
vector.insert() and operator overloading
 
Hey all, In my program, I have a class Route. It has a vector<string> property. After an initial vector has been populated, the user may have to concatenate an...
[15 replies] Last: Here ya go, this one doesn't change the original route. Route Route:... (by pgiovanni)
October 2019 Pages: 123456... 10
  Archived months: [sep2019] [nov2019]

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