General C++ Programming - February 2018

Help filling new dynamic array of type pointer
 
Help I am making a program to add sparse matrices from two files into an output file. My problem is I cannot figure out how to grab the correct information from...
[3 replies] Last: Note that you try to print size1 elements from m1. There are no size1 ... (by keskiverto)
Why do we need heap ?
 
why do we need heap if we can simply do this: Player *player; void createplayer() { Player newplayer; newplayer.health = 100; newplayer.immortal = ...
[7 replies] Last: but in visual studio when i try to go address of newplayer object it ... (by doug4)
Composition
 
Hi, may I know if there is a way to B object without calling A object beforehand? class A{ private: int attackPower; public: void setPower(){ c...
[2 replies] Last: Duplicate of: http://www.cplusplus.com/forum/beginner/232211/ Please... (by MikeyBoy)
Is *(new Object()) a bad practice?
 
In Java and other languages it is much easier to create a new object for a function, such as: doSomething(new Object(1, 2, 3, 4)); In C++, the equivalent fo...
[5 replies] Last: Thank you all for the answers! (by daverave1212)
C++ Queue Code: Keeps spamming output until it crashes
 
#include <iostream> #define MAX_SIZE 100 using namespace std; int main() { int item, choice; int rear = 0; int exit = 1; cout << "\nSimple Qu...
[7 replies] Last: Oops... yes, you're right. Thanks! Although my point still stands. ... (by MikeyBoy)
Identifying values between tags [Help Needed]
 
hey all, recently, I have been trying to construct my home-brewed way of identifying values between tags. I am trying to find values between tags, but the solut...
[7 replies] Last: Thanks everyone for the help, but I ended up deciding to simply use JS... (by DrewRiddles)
C++ - Calling a virtual function in another class
 
Hello, I'm trying to call a virtual function declared in another class. I understand that the normal method of creating an instance won't work. I can't see...
[9 replies] Last: which is declared as a non virtual function. Actually, assuming Do... (by doug4)
While Loop Word Search
 
Hello, I am needing to write a word search program that will take the user's input and let them know how many times the word or phrase input is found in the ...
[4 replies] Last: > may i ask why you choose to use std :: im very new to C++ so im tryi... (by JLBorges)
Can I create variables during compiling time in in c++
 
I appreciate it if someone has the answer. Can I create variables during compiling time in in c++. I have an array with 729 elements. I want to divide it...
[2 replies] Last: If you already have defined and initialized the array of 729 elements ... (by Peter87)
Hello Admin/Moderators! There is someone spamming here!
 
Hello Moderators/Admins: Good day. Upon checking the threads here in General C++ Programming, there are others abusing the forum, and also repeating posts. I...
[1 reply] : I am trying to report the spamming activities, but it still kept on cr... (by kindgnice)
HELP
 
Instead of copying the assignment from your school, give some examples of things you have tried. We aren’t here to do your homework for you. We would be glad ...
[1 reply] : @DrewRiddles is extremely right! P.S. Bro, I noticed some spamming a... (by kindgnice)
Is *ptr++ = tolower(*ptr); well defined?
 
A guy in the office thinks that the subject code is well defined. I'm pretty sure that it's undefined behavior because the post-increment could occur before or ...
[16 replies] Last: > The question is whether the post-increment of the pointer is guarant... (by JLBorges)
Possible While Loop Problem
 
I am trying to practice doing random c++ programs and in one I came across the problem where my program won't stop accepting inputs. I am using a pearsons site ...
[1 reply] : Once inside your while loop, onesDigit never changes. tensDigit nev... (by Repeater)
how can I printed the result with 10 numbers per row and with 5-character width for each number?
 
#include<iostream> #include<iomanip> int counter = 0; for (int n = 2; n <= 200; n++) { //(1) check if n is prime or not bool isPrime = true; for (i...
[1 reply] : adding if ((counter % 10) == 0) { cout << endl; } afte... (by fcantoro)
Matrix class using vector
 
Hi, I want create a matrix class using the STL conteiners vector, but I have some problem when I want set a value of the matrix. Could anyone help me? #inclu...
[2 replies] Last: Your code with code tags: #include<iostream> #include<vector> using n... (by fcantoro)
./....
 
....
[3 replies] Last: @DrewRiddles is right. This is the purpose of a forum. If you are dele... (by kindgnice)
by Tduck
How do you find missing brackets/braces?
 
I've been searching for hours in my code, and I simply can not find where the missing closing bracket is. There are 58 { open brackets, but only 57 } closed br...
[10 replies] Last: Yes, get a decent editor and use the editor’s ‘ find-matching-brac... (by Duthomhas)
Need help with move constructor/assignment operations
 
I am completely lost in move constructor/assignment functionality. I am writing Pointer class for Arduino, where I don't have access to std cast/move operation...
[4 replies] Last: Thanks a lot for this explanation. (by afedorov)
[Solved]
 
Hello! I am currently having quite the problem while developing my software. I cannot seem to find a decent way to find all values that match the delimeters. fo...
[4 replies] Last: std::quoted is a C++14 feature. What compiler do you use? (by Thomas1965)
by Mk87
random generator binary numbers
 
according to this random generator number code: srand(time(0)); for (i = 1; i <= 26; i++) { bufferData.push_back(i); } for (i = 1; i <= bufferData.size(...
[2 replies] Last: vector <bool> is sometimes optimized to store single bits on many impl... (by jonnin)
February 2018 Pages: 123... 11
  Archived months: [jan2018] [mar2018]

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