General C++ Programming - September 2020

by kitfox
How to use smart pointers to expose internal parts of a class?
 
I'm trying to figure out how to adapt code written using raw pointers to use smart pointers. I have...
[3 replies] Last: Smart pointers do not replace plain pointers -- that's a common misc... (by mbozzi)
by kitfox
Best way to allocate a block of memory?
 
I want to allocate a large block of memory to store image data. It will be several kilobytes in siz...
[4 replies] Last: If you want to dynamically manage memory and don't want to use std::v... (by deleted account xyzzy)
Is Java easy to learn after C++?
 
Hello. Does anyone know if Java (or, whatever the game 'Minecraft' is written in) is easy to learn ...
[9 replies] Last: the biggest problem I have with java after c++ is that there are a doz... (by jonnin)
Reading hex offsets/data from ifstream file?
 
Hello. Can anyone tell me if it is possible to read a hex offset such as 0x00000001 (0x1??) Like in...
[3 replies] Last: int offset; mystream.read((char*)&offset, sizeof(offset)); // if th... (by dhayden)
by Borneq
Odd template
 
In type_traits I can see: // [func.require] paragraph 1 bullet 1: struct __result_of_memfun_ref_im...
[2 replies] Last: To explicitly answer each of these: std::declval is a function, so th... (by MikeyBoy)
#ifndef include guard help!
 
Hello. I am new to using #ifndef, #ifdef, #endif and such. I put the following at the top of my head...
[13 replies] Last: Problem solved. Thank you all for helping!! (by SirEnder125)
by its007
Filling 3-d array with random number with conditions
 
Hello all, First off, I would like to thank you for reading this. I am grateful for any help/hints ...
[5 replies] Last: Thank you jonnin and coder777! I appreciate the help much very much. ... (by its007)
Manipulating an array (creating destructor, shifting elements forward/back and printing the array)
 
Need help finishing up the yet to be defined functions in this chunk of code. #include <iostream> ...
[1 reply] : moveTowardEnd( index ) { /* s = size WHILE s > index : ... (by nuderobmonkey)
User input after *argv[] input
 
Hello. I would like to know how to get a file name input into int main(int argc, char *argv ) ...
[8 replies] Last: Thank you. I'll try to remember all this stuff... I should have learn... (by SirEnder125)
Certain input value causing crash
 
Dear Users, The code blow keeps craching for input 15. I thought it was some Windows 7 issue. Then ...
[5 replies] Last: Change to int* p = new int ; p = 2, p = m; works ok on my win... (by seeplus)
C++ code for reading text from file? (help)
 
Hello. I was wondering if anyone could tell me how to do this. Read the text after the inputted l...
[4 replies] Last: just do getlines and discard the ones you do not want to skip a line o... (by jonnin)
Does destructor of a polymorphic base class that is protected need to be virtual?
 
If I have a base class for an inheritance tree, and the destructor is declared protected, do I still...
[3 replies] Last: thanks!! (by JUANDENT)
How do I use a boolean vector with if-else?
 
Let me explain exactly what I mean. I've got a recursive function that works with roughly the follo...
[1 reply] : .at is notably slower than notation because it checks i to be valid.... (by jonnin)
by jerryd
wofstream problem
 
cplusplus forum, Windows 7, MS VS 2017, C++ I have a wstring that contains a unicode charact...
[7 replies] Last: cplusplus forum, I was able to find a way to create a windows file na... (by jerryd)
What does ^= mean and how do I use it?
 
I've seen this operator in c++ codes and I don't know what it means. Thanks for answers in...
[4 replies] Last: Ah, thanks for explaining this. I'll try using this in my code. (by SirEnder125)
Encryption code not working
 
Hello. Can anyone here tell me why this code won't work (you can run it to see what I mean) #incl...
[2 replies] Last: I figured out what was wrong, I should have done: data = encrypt(dat... (by SirEnder125)
How to combine hash values using std::hash
 
I have a type with 2 int data members. I want to calculate a GOOD hash value and since std::hash exi...
[12 replies] Last: perfect hashing is usually reserved for a static set of known data suc... (by jonnin)
my compiler says expected primary expression before '<<'
 
#include <string> #include <fstream> using namespace std; struct TempScale { double fahrenh...
[2 replies] Last: You're also attempting to use the name of a class as if it were an obj... (by Ganado)
by AmirRN
Why const reference string
 
Hi everyone, I just wrote this piece of code to test something, but it didn't go through the GCC-com...
[1 reply] : is not why you need a const reference, but why do you need a non-const... (by ne555)
Eight Queens Problem 2-D Array Help
 
Hi I am currently trying to work on creating a function where it determines if a queen is under att...
[1 reply] : TBH, the whole idea of storing the row in a 'Queen' object, and the co... (by salem c)
September 2020 Pages: 1234
  Archived months: [aug2020] [oct2020]

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