Beginners - February 2022

by hevi
No clue
 
Hi, got a problem with my code. Keeps saying error : cant convert string to int. But Im not trying to do that :D Cant figure out why it thinks that. Sorry for t...
[7 replies] Last: It's because in the info function you put int first, string second and... (by mikef)
using const with function
 
what is the purpose of using const with function void readData () {} void readData const () {}
[3 replies] Last: It is a promise that the function will not modify the object that it's... (by Peter87)
Stuck trying to #include interdepenant headers
 
I have two classes and in each class I would like to have a pointer to an instance of the other. But the compiler is complaining because I can't use one type ...
[4 replies] Last: >You must forward declare ClassB. and you must forward declare ClassA ... (by ne555)
Error code not in scope
 
I have been working this program for a while for my class so far it will not compile. The instructor was nice enough to let us take a screen shot but I only got...
[4 replies] Last: Simply without input validation consider: #include <iostream> using... (by seeplus)
by AkiraC
How to perform insertion sort for array with more than one variable?
 
Hi, I have an array with more than one variable, eg: ID, name, gender etc. And I want to perform sorting for the data in the binary file, so I decided to use in...
[2 replies] Last: There's something oddly familiar about that code.... Mmm, interesting... (by salem c)
Printing out name of station that matches max and min temp in a file
 
Hello, I have a file that has a bunch of information in it about weather data. I currently need to find the max temp and the min temp and print out the stations...
[6 replies] Last: Another way of getting rid of the preceding whitespace is: while (st... (by againtry)
sample without replacement - efficient way
 
Greetings! I have an array of which I would like to draw n samples without replacement. The quality of the randomness as well as computational efficiency is imp...
[12 replies] Last: [quote=mbozzi]Could you be thinking of Fisher-Yates? I was! But I had... (by lastchance)
by hevi
Decompressing RLE
 
Hi, I have an RLE compresser which works perfectly fine, but how do I decompress it? I have no idea how I would come about doing it. Any help? Below is compress...
[15 replies] Last: hevi, STOP reporting posts you don't like. That makes people consider... (by George P)
Size of Char in C
 
Hello, I ran the following code in Visual C++ and I have 1 and 4 In GCC 11.2 I have 1 and 1 Why in Visual C++ do we have 4 for a character? Thank you ...
[6 replies] Last: sizeof(char) is always 1. (by Peter87)
Keep getting 4 errors in my code and dont understand
 
hey. in my code im keep getting errors and i don't understand what they mean and how I can correct it. Im fairly new to C++. #include <stdio.h> #include...
[4 replies] Last: If you have something like a vector, then you can sum the contents eas... (by seeplus)
C++ program to read integers until 0 is entered using sentinel.
 
Hello, I'm trying to write a C++ program to read integers until 0 is entered using sentinel. (1) Display the sum of the two-digit numbers (both positive and ne...
[8 replies] Last: [See also http://www.cplusplus.com/forum/beginner/282399/ ] (by seeplus)
I need help with this assignment
 
I need to write a code that loads 5 numbers from a user and sums up the ones that have only 2 digits. I tried with if statements directly but couldnt get it to ...
[3 replies] Last: #include <iostream> constexpr int NoNums {5}; int main() { int re... (by seeplus)
C++ program to read integers until 0 is entered using sentinel.
 
Hello, I'm trying to write a C++ program to read integers until 0 is entered using sentinel. I want the before 0 integers to be read but the 0 not to be and the...
[1 reply] : [Duplicate post] (by seeplus)
I can't figure out this assignment.
 
Hello, I'm trying to write a C++ program to read integers until 0 is entered using sentinel. I want the before 0 integers to be read but the 0 not to be and the...
[5 replies] Last: [See http://www.cplusplus.com/forum/beginner/282399/ ] (by seeplus)
I can't figure out this assignment.
 
How would I go about making a different message appear when no positive integers or negative integers are entered, instead of it showing a really large or small...
[3 replies] Last: Perhaps: #include <iostream> #include <limits> constexpr int MinIn... (by seeplus)
how to get a file line to do more than just print? (1,2)
 
hello, how can you get a text file with data like this do more than just print out a line. Fred Farkle 72 69 17 21 23 14 22 Tina Moffett 81 86 23 25 19 25...
[21 replies] Last: I liked my highschool's system best of all. 10 points per grade, so 9... (by jonnin)
operator overloading
 
In my book the below code for the operator + is written in a way that makes a new temporary Date and returns it without affecting the original object. What if I...
[6 replies] Last: If you want to something custom & weird, I recommend using things like... (by jonnin)
by lare26
Disfunctional Function Declaration (1,2)
 
I am trying to figure out why this doesn't work. I thought I was doing it correctly. But the scope seems to be quirky. It says the variables are not declared i...
[32 replies] Last: [Moved making a game chatter here]: http://www.cplusplus.com/forum/lou... (by George P)
by vboro
do{...}while(...) loop to chech array?
 
Hi! I have an array with numbers from the user. My task is to then std::cin numbers and check if it's in the array. If it is, the program should quit the loo...
[5 replies] Last: seeplus's first sugestion worked perfectly fine, just what I wanted my... (by vboro)
Constructor syntax
 
Someone could explain me the following declaration for the contructor? class GameError : public std::exception { private: int errorCode; std::string...
[3 replies] Last: As you browse those those linked pages, you should also notice that ... (by keskiverto)
February 2022 Pages: 123... 7
  Archived months: [jan2022] [mar2022]

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