Beginners - November 2019 (Page 5)

by vysero
Variable instantiation
 
I am confused about some feedback I got: "Member variables should be instantiated in the class constructor, not the declaration." I declared the variable ...
[11 replies] Last: as far as I remember, variables are initialized and objects are insta... (by MikeyBoy)
Deep copying vector of pointers to fewer objects
 
I have been researching how best to implement a design I have in mind for a class, in which I need to have a container, that contains pointers to an object I wi...
[2 replies] Last: for K in range(len(v)): index = find(v , v[0:K]) //looking for a ... (by ne555)
C++ #include <regex> Usage - replace_regex()
 
Let's say I have a text file with the format: horsey"test"log And I want line to be: "test" I would use std::regex_replace() for this. Although I'm having ...
[4 replies] Last: pos1 = s.find("\"", 0); will give you the first " then pos2 = s.fin... (by ne555)
by Hajo93
Struck with input
 
I'm in the process of creating a code. Where I can enter student number, name and age. It works as long as I just type in a first name like Mark, if I type in a...
[1 reply] : Just use C++. #include <iostream> #include <string> using std::stri... (by Repeater)
getting program to end loop and count properly
 
Hello, I am a new student learning C++ and I am having trouble with my program for a class that uses 2 arrays to count the number of upper and lower case letter...
[4 replies] Last: I keep getting an error code when using != int the strcmp That's not ... (by coder777)
Change color of the text that user inputs when prompted .
 
So when the user is prompted to input data using their keyboard. That input appears on the screen. I want to change the color of just that text to easily distin...
[3 replies] Last: Hello mdh1559, The code used in the article is nice, but a bit long. ... (by Handy Andy)
Evaluating post/pre dec/increment
 
This is driving me NUTS!!! Why are different online compilers giving my different results for this code? #include <iostream> using namespace std; int ...
[6 replies] Last: If that is the case, then, as x appears in that chain before increment... (by lastchance)
List sorting problem
 
Hi, I'm not sure how the sort() function for list objects works. I'm trying to sort a list of album titles alphabetically, but I'm having very little success. ...
[10 replies] Last: Thanks for the documentation. I learned several things. (by jjordan33)
by raneie
Arrays with integers and strings?
 
Hi! I'm working with arrays and I'm wondering how I would put an integer and a string into the same array, if that's possible? Here's my code: #include...
[7 replies] Last: I did the entire project again but with what you suggested jonnin and ... (by raneie)
Recursive timer implementation
 
I have a quick question on how I can implement a timer where it will keep track of and display how long it took to execute the program. For context my progr...
[1 reply] : Something like this, perhaps: #include <iostream> #include <ctime> #... (by JLBorges)
Help With Class Interactivity!
 
I'm trying to write a program that deals with information from two separate classes. There's an emphasis on restricting access to data between the two, and inst...
[1 reply] : Main #include "header.h" int main() { int counter = 0; int ... (by confundido)
by Frrag
getline dosn't work
 
i have problem with reading the line of file; the file: https://pastebin.com/D9L1ScWW file testing: file1 contain "noting but everything"; file2 contain "not...
[7 replies] Last: You need to use an endl (or at least a flush ) after printing the ... (by dutch)
by obeeey
Global variables
 
Hello, I have a problem with declaring a variable which can be used in functions. Let's say I want to do something like this: int G_NUMBER; //a global varia...
[1 reply] : Your compiler should not be having a problem with line 7. #include <... (by George P)
UML class diagram to code translation (1,2)
 
Hello Everybody, I have translated the following class diagram (click on the link below) into c++ code. This is my early stage experience indeed for such an...
[23 replies] Last: we can circle back to it but even with advanced algorithms like that, ... (by jonnin)
Dividing contents of 2 dimentional array into one array
 
Why does my avgHi array output zero if I divide the contents of the two arrays but if I add or subtract them, then I get the correct result? for (int i = ...
[2 replies] Last: Thank you. I was able to fix this by adding (float) to one of the numb... (by Esmith0550)
Take in 'x' amount of a string and reverse it
 
Hello, folks. The main objective I am trying to accomplish is taking in a user string and saving the reverse to it. I also must take in an 'x' amount of strings...
[5 replies] Last: #include <iostream> #include <string> using namespace std; string ba... (by lastchance)
Random number for 10 to 99
 
The question was to generate a random number from 10 to 99, inclusive. I know enough to write the code below to generate 1 to 99. But is there any way to do jus...
[2 replies] Last: I think you should change this cout << (rand() % 98 + 1) to co... (by digozido)
Breadth first search and depth first search examples
 
Can someone post a code for each traversals using strings? I need to get some ideas where to start. Simple examples
[no replies]
MonteCarlo Integral Program bad results
 
First shot at coding MCI. I can't figure out how to generate random floating point integers which would probably increase the accuracy of my results, so for now...
[7 replies] Last: Ahh, how could I miss that!? I had it in my pseudocode too. Thanks for... (by jgialis)
abstract class error
 
Hey guys, so a pretty beginner exercise but I decided to give it a shot, it's from a book I am currently reading on data structures and algorithms, the proble...
[2 replies] Last: *edit again, spotted the bug I subtracted 10 instead of 0.10 now fixed... (by adam2016)
November 2019 Pages: 1... 34567... 17
  Archived months: [oct2019] [dec2019]

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