General C++ Programming - June 2020 (Page 5)

by doug4
One more line of code I need to make it work
 
I would try this if (y == 0) { std::cout << "Cannot divide by zero. Operation aborted..." << s...
[7 replies] Last: And the spampost is gone :) (by MikeyBoy)
Output affected by placement of delete statement
 
Hello, I'm a computer science student and am working on a homework problem. I have already solved i...
[5 replies] Last: going out of bounds of a block of memory can cause any of many unpredi... (by jonnin)
Currency to words C++
 
Im trying to make a code that displays currency such as (312,12) in words (three hundred twelve doll...
[4 replies] Last: Thanks dutch for your help i was able to get the code working. after y... (by somedude)
swap
 
do u know whats the difference between storage.swap(new_storage) and std::swap(storage,new_storage),...
[1 reply] : Typically, prefer the specialized a.swap(b) over the more generic s... (by mbozzi)
template
 
#ifndef FAST_QUEUE_H #define FAST_QUEUE_H #include <iostream> #include <vector> #include <algorithm>...
[4 replies] Last: thanks (by closed account jGAShbRD)
Searching for a word in text file
 
Hi im trying to write a program that reads in a text file. The user can search for a specific word a...
[2 replies] Last: Maybe like this: #include <iostream> #include <fstream> #include <str... (by Thomas1965)
mod help
 
i have some variables. int first = shows the start of queue int count = size of my vector int number...
[1 reply] : #include <iostream> int main() { const int Capacity = 4; ch... (by dutch)
Bernoulli formula with more than one k
 
I want to make a program in which I calculate the probability with Bernoulli for multiple k's (for e...
[1 reply] : You shouldn't keep inputting new k values. Just input the maximum one.... (by lastchance)
by volang
Size of a forward_list
 
I dont want to keep track of its size on my own, so I wonder if I instead can update a member varia...
[16 replies] Last: It could still be possible to have O(1) splice with size. Like jonnin ... (by helios)
testing.
 
im getting an error when i was trying to test my code i got a main.cpp and a class main.cpp:5:13: e...
[1 reply] : You have to put an actual type in the <T> when declaring an object. Fa... (by Ganado)
vector
 
if i have a vector a of size 10 holding 10 elements and another vector b of size 20 holding 10 elem...
[2 replies] Last: for anything you swap, the a becomes b, and b becomes a, FULLY, not pa... (by jonnin)
Trying to calculate with the Bernoulli formula
 
I am willing to calculate with the Bernoulli formula. For that I have made the following code: #i...
[8 replies] Last: Ah, duh. (by helios)
Loop
 
How can I print 2 line like this to console? 1 11 2 12 3 13 4 14 5 15 6 ...
[11 replies] Last: try this .... #include<iostream> using namespace std; int main() { ... (by aniksh44)
vector help
 
i have a vector<Typename> which is a container with unknown amount of elements. i have a int first =...
[1 reply] : Is this a continuation of: http://www.cplusplus.com/forum/general/2710... (by keskiverto)
by Vycues
Which event should code go to restrict areas where a picture box is dropped on a form
 
I am trying to make a card game in a windows form. I want to check the image string name in the pict...
[no replies]
by Ema00
Login function
 
Hello everyone, in the code below I tried to make a simple staff management program for school, I wa...
[6 replies] Last: A tip for making your code cleaner and better looking: You can add a f... (by miguelol)
list/array of constant pair values at compile time
 
How do we have a list/array of constant pair values at compile time so it would be passed as two arg...
[7 replies] Last: Possibly relevant? http://www.cplusplus.com/forum/general/271007/ (by helios)
by volang
Map or unordered map?
 
I have a map where the order never matters. The only important thing is that I get direct / fast a...
[7 replies] Last: That's true (except if you don't need access by key) The OP specific... (by dhayden)
for enum cannot work
 
Why is this not working enum L{ j, k, l }; int main(){ for ( int i : L) cout...
[2 replies] Last: That’s not how for loops work. You should try using a switch sta... (by Gringoliath)
exceptions
 
template <typename T> T & FastQueue<T>::front(){ if (number_of_elements == 0) throw std::out_o...
[1 reply] : It's a type, not a value, so throw std::out_of_range(); . (by helios)
June 2020 Pages: 1... 3456
  Archived months: [may2020] [jul2020]

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