General C++ Programming - August 2019 (Page 3)

Hash table question
 
Hi, everyone. I'm working on a hash table program, but while I run it, the windows just ended with "Process exited after 2.92 seconds with return value 32212254...
[18 replies] Last: To deal with hash collisions, you look for an empty slot in the hash t... (by dhayden)
by colt
'std::bad_alloc' when working with strings
 
Hello I am receiving the above error message when a method returns a string. This is the method that fulfills the string and then return a copy of it: st...
[5 replies] Last: > run your program through use a debugger >> Well, I use GDB. show th... (by ne555)
Why doesn't this build
 
I get an error argument of this type const char is incompatible with parameter
[8 replies] Last: thanks salem, that fixed it (by piratekingluffy)
by stav
static initialization in header only library?
 
Hi, I want to write a logging library and so im currently in the process of figuring out how best to go about it. So far im imagining doing something like this:...
[3 replies] Last: Thanks alot guys (by stav)
by frek
Constexpr in C++ (1,2)
 
Hello all, Is what I know of constexpr written below all correct? Should add something to it, please? - A constexpr symbolic constant must be given a valu...
[36 replies] Last: Thank you very much. I don't think I have another question in this ca... (by frek)
How do I stop ..eof from reading the last line of input twice?
 
#include <iostream> #include <queue> using namespace std; int main () { int n, num, cust; char type; cin>>n; queue <int> q; vecto...
[7 replies] Last: No, I get its purpose, but it still feels like the sort of thing that ... (by Albatross)
Adjacency list, array of pointers
 
Hi guys, can someone explain me why to use a double pointer in the class graph? I really don't understand this line : this->array = new AdjList*[Algorithme::nb...
[2 replies] Last: OP's code, reformatted: #include <cstring> #include <fstream> #includ... (by Albatross)
Inheritance question
 
I have a parent class with 2 child class. I want to use dynamic casting to change my parent class from base to derived so that I can access the data and methods...
[1 reply] : . I want to use dynamic casting to change my parent class from base t... (by Repeater)
why the graphics.h and conio.h was losed? (1,2)
 
why the graphics.h and conio.h( textforecolor(), textbackcolor(), gotoxy() and clear() ) was losed?
[33 replies] Last: That Sams book is an older version of the book I linked. There are so... (by George P)
by a00
do header files get compiled
 
I write a program called main.cpp, i know the main.cpp get compiled into object file and get linked. I wonder if header file(for example somethings.h) get co...
[6 replies] Last: Okay, I suppose I'm already doing that. It also occurs to me that the... (by mbozzi)
can't remove duplicated objects from vector
 
I thought object 3 and 4 will be erased and this should output 1 and 2, but it gives me 1,2,3,4, why is that? #include <iostream> #include <vector> #include <...
[2 replies] Last: std::unique only removes CONSECUTIVE duplicates. Your nominally equal ... (by lastchance)
Hash table with speed required
 
Hi, everyone! I'm a C++ beginner, and here is a project which is about implementing a hash table to store the patients' data in a hospital. As the attached dat...
[2 replies] Last: as fast as possible means no collisions, don't even detect or handle -... (by jonnin)
How to write code for this? - Class
 
Hey all, I’m very new to c++ and trying to learn from doing exercises. I kind of stuck and need help. 1) I have main.cpp, rectangle.h and rectangle.cpp ...
[3 replies] Last: rectangle.h // #include guard: https://en.wikipedia.org/wiki/Include_... (by JLBorges)
sorting and removing duplicates from vector
 
Hi, I understand that the code below sorts the vector and remove the duplicates, but can someone tell me what does the unique method return? I know the erase me...
[2 replies] Last: Some variants: #include <iostream> #include <vector> #include <set> #... (by lastchance)
pointer inside struct
 
Hi guys, can someone explain me the difference in meaning between struct AdjListNode { int dest; int weight; struct AdjListNode* next; ...
[12 replies] Last: @jlb, that is why I personally NEVER declare more than one variable at... (by George P)
Size of Class/Object
 
Two queries: 1. why size of Base class object is getting 8 bytes instead of 5 bytes(1 for char + 4 for int)? 2. And size of class is equals to size of object ...
[3 replies] Last: A couple of links for the curious. https://www.kernel.org/doc/Document... (by salem c)
How can I make my solution more efficient?
 
I'm having trouble with a competitive programming problem, here it is. Farmer John's N cows (1 <= N <= 100,000) are standing at various positions along a long ...
[11 replies] Last: So, you're saying zero holds a special value, but is that value suppos... (by Niccolo)
Assigning part of a 2d array to a new 2d array
 
I am trying to do this, but it is giving me "initializer fails to determine size of ‘b’" int main() { int a ; a = 1; a = 1; ...
[7 replies] Last: @ fewdiefie You forgot that a is a 2D array, so a is the address... (by Duthomhas)
FPS game programming
 
Hello, I have spent the last 2 years learning the DirectX 11 technology to build my own FPS video game, I can write a fully functional rendering system and a ba...
[7 replies] Last: yea. I did physics sim / flight sim, just sans graphics (or on one or... (by jonnin)
Using nested if for evaluation of signum function
 
The function to be evaluated via C++ code is: Y = 0 if x = 0; Y = 1 if x > 0 Y = -1 if x<0 The value of x is input from the user. "Nested if" statements are t...
[14 replies] Last: but, lastchance's answer is probably the best way to actually code it ... (by jonnin)
August 2019 Pages: 123456
  Archived months: [jul2019] [sep2019]

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