General C++ Programming - July 2022 (Page 2)

by hbcpp
Smart pointer confusion (std::unique_ptr in function argument) (1,2)
 
this is my first time working smart pointer and I getting confused with this: void test(std::unique_ptr<int> s) { cout << *s;//(s == nullptr); } int main...
[29 replies] Last: "I saw the light, I saw the light No more darkness, no more night Now ... (by seeplus)
how to get locale based digit groups separator (ansi c)
 
I've tried searching for this information on the web but keep getting directed to either c# or c++ solutions that rely on sprintf etc, but as noted at https://m...
[8 replies] Last: I may have had an ABI issue, I did a rebuild during my attempts to fin... (by awsdert)
dynamic array allocation
 
Hello. Had an assignment using dynamic array allocation. Instructions: Write a program that prompts the user to input the length of a string as an integer, fo...
[4 replies] Last: There is also a design decision about how to handle less consistent us... (by keskiverto)
by Cj230
Desperate for Explanation on I/O Assignment
 
Hello Everyone! I have a programming assignment I have been working on all day. I'm pretty sure I've just been overthinking it so I am going to post on here to...
[3 replies] Last: I have been working on all day So post your code so that we can see... (by seeplus)
by t im
About the upper_bound Function
 
Edit: In Solution 2, if I use upper_bound function instead of the menber function of multiset, time limit exceeded will alse be reported. So, I think the differ...
[3 replies] Last: Thanks for your answers that benefit me. (by t im)
assistance with class code
 
Hello, been having issues with this program that uses classes. Any help would be appreciated, but please make it as simple as possible. This chapter defines ...
[15 replies] Last: sorry for not responding at all, was in the hospital for 3 days. Here... (by seeplus)
by t im
About the loop condition
 
In case of the following two for loop: // case 1 for (int i = 0; i < n; i++) something; // case 2 for (int i = 0; i <= n - 1; i++) something; ...
[3 replies] Last: Thanks for your answers which solve my confusion. (by t im)
does all stream object have buffer except cerr?
 
I just started learning about stream and I am not quite sure how it works. correct me if I am wrong. A buffer is a memory region in which data is stored t...
[13 replies] Last: To determine if the standard C++ streams are synchronized with the sta... (by JLBorges)
Variadic Template not working expectetly
 
Dear Community, i cannot figure out how to solve this. I am coding a Container Class and run into a Problem with my constructor. I wanna take a variadic list o...
[6 replies] Last: C++20: #include <concepts> template < typename VTYPE > struct Conta... (by JLBorges)
by ruzip
Convert any value/type to string callable from C
 
I'm trying to build a C++ function that converts any type to string. ex. int 4 will be "4" float foo with value of 2.5 will be "2.5" .. .. So far I'm ...
[5 replies] Last: Thanks guys for the added info. Yes the C part requires it to be C99. ... (by ruzip)
Remove unwanted character from String concat macro
 
Hi I have a macro to do concatenation as below #define dd Cloud #define ff _Storage #define CCM_BRAND_CONCAT2(a,b) a##b The output is "Cloud _Stor...
[1 reply] : Pre-processor macros are very limited in what they can do. And, gener... (by kigar64551)
by Geckoo
Rosetta Site
 
Hello. I really like to "rummage" for some interesting codes on the Rosetta site which seems to me really relevant. I learnt many, many things especially about ...
[8 replies] Last: I used to work for a US technology chain store company* that had a sto... (by deleted account xyzzy)
Class as struct member
 
Suppose there is a struct with a class as a member of the struct, as in the example below. typedef struct _MYSTRUCT { int Num; Class MyClass; } MYSTR...
[3 replies] Last: If you want to define its members out-of-line (say, in a .cpp file): ... (by JLBorges)
Execute Code on task kill
 
Hi everyone, i'm currently working on a sockets project, and i want to recognize wheather the clients process is killed, but this is not windows topic. My que...
[10 replies] Last: That is good to know, thanks JL. I have never needed to do that, and... (by jonnin)
Further pure virtual calling issues
 
A debugbrk_ call occurs when I try to call pure virtual function Allocate_Square(). The debug call occurs on the first iteration through the inner loop. Stepp...
[11 replies] Last: Use a factory method: https://en.wikipedia.org/wiki/Factory_method_pat... (by JLBorges)
error C2041 - C2415 - C2426
 
I want to make a dell file, but there are some errors my code #include <Windows.h> #include <iostream> #include <string> #include <TCHAR.H> using namesp...
[6 replies] Last: thanks for replay yes i use vs 2010 , I made a lot of dell files wit... (by Hawlong)
why is istream::read cast to char*
 
1. why do I need to reinterpret_cast the 1st argument of read() function of ifstream into a char* when reading a file and also casting the 1st argument of write...
[3 replies] Last: Unlike other languages (Java, C#, etc.), there is no explicit "byte"... (by kigar64551)
template metaprogrammingNewTupleType_ not compiling
 
I have errors in the following: template<typename TVal, size_t N, size_t M, typename TProcessedTypes, typename ...TRemainTypes> struct NewTupleType_; ...
[2 replies] Last: Looks like the usage of NewTupleType on line 42 can be replaced entire... (by mbozzi)
Error when filling a matrix using Eigen
 
I have the MATLAB code: Nx = 10; Ny = 10; %X,Y defined u = (Y-0.5).^2 .* sin( (2*pi / Lx) * X); %Y.^2 .* sin( (2*pi / Lx) * X); uh = fft(u, ,2); %use discre...
[5 replies] Last: I did find the issue and to fix it I used seq() instead of seqN... (by JamieAl)
Tag2ID is giving me trouble
 
Hi, I am trying to create a metafunction that returns the index of a type in a list of types (Tag2ID) but am having trouble: template<typename ...
[5 replies] Last: You're right, thank you. (by mbozzi)
July 2022 Pages: 123
  Archived months: [jun2022] [aug2022]

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