Beginners - July 2020 (Page 7)

if/for/while do
 
pals, have to write a code which: Prints out for "n" nr. of times , the last result of the equation a+b-c , if the sum of all the results is bigger then...
[13 replies] Last: Maybe the 4th requirement does not mean the sum of all the results, bu... (by Manga)
How to make a class "private"
 
As a minimal example, consider a library that provides a `Car`, and the `Car` has an `Engine` in it: car.h #ifndef CAR_H #define CAR_H class Engine {...
[7 replies] Last: Thanks. I've edited my post. (by dhayden)
by sparki
Conversion to string from int
 
Hi, why is the output some garbage value at the start of the first 2 bits? and then fine for the rest of the bits? I don't understand. Hope someone is able to h...
[1 reply] : That memset looks wrong. array is an int pointer, size 8 bytes (probab... (by Repeater)
by Xyz57
Code debugging assistance
 
I could use some help with debugging my code. I am not very good at debugging code so I could use some assistance with what I might need to change in order to g...
[4 replies] Last: BTW static const PI can best be put inside the class (it's not a data ... (by againtry)
by momof4
how to draw a number in the thousands
 
I have a function to draw numbers 0 through 999, but now I'm working on a project that is going to require numbers in the thousands and possibly ten thousands. ...
[2 replies] Last: How about: void display_number(int num) { for (char digit: to_s... (by dutch)
Read file and input into vector
 
Hey everyone! I am pretty new to C++ (just started this month) and will appreciate if someone can help me here. I have a text file with the following fixed con...
[5 replies] Last: Maybe something like this: #include <iostream> #include <fstream> #... (by dutch)
by momof4
move once per click
 
I'm making a very simple game, that involves something happening when a button is pushed. Trouble is though, when I click the button the action I want happens t...
[1 reply] : you need one of two things. first, check your tools to see if you hav... (by jonnin)
How can i change specific elements of an array?
 
Hello all! In the exercise that I'm working on it asks that I write an input statement that will allow the user to enter values for specific elements. here my ...
[1 reply] : #include <iostream> int main() { int a ; int b, c; std::cout << ... (by zapshe)
What shouldn't you return from a local variable?
 
Hi. I'm learning C and C++ and read somewhere that you can't return local variables like so #include "stdio.h" typedef struct Foo { int fooval; } F...
[4 replies] Last: please note that a segfault is not guaranteed, so be careful when codi... (by ne555)
by momof4
Iterating through a list
 
I have a list of blocks that I have created, and I need to iterate through them and draw each one. here's what I have, but I keep getting an error : conversion ...
[3 replies] Last: This sort of problem is why we now have range based for loops: for (c... (by dhayden)
Classes and fractions
 
hey yall , im suppose to do this assignment but i haven't studied classes yet (couldn't attend online class and forgot to watch the videos), and there`s this ti...
[6 replies] Last: After you watch the videos, search for "rational" on this site. There ... (by dhayden)
C++ regex clarification
 
Can you please clarify if this is the correct approach to retrieve values of "x" and "y" from a given string? #include <iostream> #include <string> #inc...
[3 replies] Last: Raw strings were probably added mostly for regexes since otherwise the... (by dutch)
Is it possible to initialize a class' reference member inside a copy-constructor?
 
In the copy constructor for Person , how do I create a copy of Alice's pet and assign it to the copied Person's pet reference? In my current implementation, ...
[12 replies] Last: doesn't compile, conversion from `int' to `Person*' also, stack overf... (by dhayden)
do while
 
hey pals, have to write a code that : identifies how many times variable b got incorrect values. Var.b got randomly values from 0-100, but only values from...
[3 replies] Last: thanks (by MaxGreen)
Range based for loop in cpp
 
The below code snippet is python range based for loop with the increment of steps by 2. for x in range(1,10,2): Result:1,3,5,7,9 print(x) ...
[9 replies] Last: You may use C++17 and overload of << operator #include <iostream> ... (by TomCPP)
C++ debugging help
 
I have an assignment where I need to find the area of a cylinder. I am only able to get the output of the circumference and the area, but they are both 0. Curre...
[5 replies] Last: Just for interest sake after a bit of compaction etc ... #include <i... (by againtry)
How to write a method to cout elements (of user-defined type) from sequential containers?
 
I'm designing a little function for general purpose use. The function is called StrItems() and its job is to return the string-representation of a sequential ...
[6 replies] Last: [quote=ElusiveTau]My guess is that execution tries to run to_string(ob... (by Ganado)
by Mif
Can anyone help me with switch loop?
 
The code compiles and I don't get any error the problem is the loop when you choose for the first time the program does what is asked to, but starting at the se...
[6 replies] Last: glad you got it. FYI c++ does not recommend C-strings and printf, sc... (by jonnin)
Returning values from a void function
 
I am trying to return the values avgTime and avgGross from the void functions but have not been able to find anything that works. Typically, I would just put th...
[7 replies] Last: void readFile() - read the contents of the input file Your calcAvgGr... (by dhayden)
Deleting 1 copy of a shared_Ptr
 
Hi,how could I set a shared_Ptr to nullptr? Concourse has a std::shared_ptr<Text> called text. It also has a setter and getter. This currently doesn't work. Th...
[9 replies] Last: > I think that may just be a mistake with the const. that's quite a de... (by ne555)
July 2020 Pages: 1... 56789... 12
  Archived months: [jun2020] [aug2020]

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