General C++ Programming - February 2022 (Page 3)

Is there a way or function to check if a float is assigned a value to?
 
I want to find the max and min value from numbers of a csv file. I don't know the range of the values, so I can't really just assume an initial min or max value...
[1 reply] : Assume that the numbers are of type float, then you can use these for ... (by seeplus)
How do I populate my vector that is located in my struct? See the 2nd to the last for loop
 
#include <iostream> #include <vector> #include <string> using namespace std; struct Ingredient { float quantity; string ingredient; stri...
[12 replies] Last: The actual assignment was to: 1. Create a recipe struct 2. Create a v... (by seeplus)
by ttpjd1
Issue with C++ dispatch to base
 
Please forgive me if I fundamentally misunderstand something about dispatch in C++! The code as pasted below works as intended. However, if I uncomment/ad...
[1 reply] : This compiles: #include <iostream> class Something {}; class Somet... (by seeplus)
by frek
Lambda
 
1) Why is not the lambda inside the function called, please? #include <iostream> void test() { int n=0; [&]() { std::cout << "Inside the lambda!\n"; ++n; };...
[9 replies] Last: @ frek, a book on lambdas I found useful is Bartłomiej Filipek's "C++... (by George P)
I need to generate a unique random number everytime a user press y
 
#include <iostream> #include <time.h> #include<windows.h> using namespace std; int main () { srand(time(NULL)); int arr ={1,2,3,4,5,6,7,8,9,10...
[5 replies] Last: No, there is no need to remove any of the elements, from the front or ... (by George P)
What would be the best strategy for grouping these objects together? (vector, array, etc)
 
My question is what would be the best way to organize objects(both the initial 12 and the offspring to come later)? I feel that a vector would be the best way o...
[1 reply] : its up to you. KISS suggests you just have your class be critter-type... (by jonnin)
by Cplusc
byte is ambiguous
 
Hello, I am including one dynamics library in my visual studio 2017 project and I am getting this error "byte is ambiguous". I tried std::byte, #undef _HAS_STD_...
[12 replies] Last: It might not hurt to consider upgrading from VS 2017 to VS 2019 or V... (by George P)
how use Multithread?
 
i did these function: void GetPixelImage(HDC HDCOrigin, int PosX, int PosY, COLORREF &color) { color=::GetPixel(HDCOrigin, PosX, PosY); } heres how i...
[2 replies] Last: This is also the case with (the bind expression created by) std::bind... (by JLBorges)
Is there an issue with my code?
 
I created this code. It runs as expected, but something seems off. #include <iostream> #include <cmath> #include <cstdlib> #include <ctime> using namespace st...
[2 replies] Last: #include <iostream> #include <cmath> #include <cstdlib> #include <cti... (by againtry)
by R3shY
DXGI Adapter RAM to String?
 
Hey im trying to get dedicated VRAM as a string with DXGI from example: https://github.com/walbourn/directx-sdk-samples/tree/main/VideoMemory I break it do...
[1 reply] : Since we've no idea what you tried, how you printed it, what you saw, ... (by salem c)
Returning the result of an expression stored in a c-string
 
Hey yall, So my assignment has once again brought me here because I am not able to figure this one out. The goal of the task is to return a short of the resu...
[4 replies] Last: short myType::Calculate(myType& Math) { Math[ Math.size()+1 ] = '... (by keskiverto)
by Cplusc
Failed to launch mpi.exe
 
I am running a code with 64 processors using mpiexec -np 64 mpi.exe, but I'm getting the error "failed to launch mpi.exe, cannot find the file specified". Any h...
[2 replies] Last: Thanks for your answer. (by Cplusc)
Why is My output rounding down
 
I have a program that outputs a list of numbers. The program is working, but the output is supposed to be 7.10 and 9.3. Instead I get 7.00 and 9.00. This is my...
[6 replies] Last: If the standard library is being used, nth_element is ideal for this... (by mbozzi)
Preprocessor OpenGL c++ issue (1,2)
 
EDIT: I HAVE UPLOADED A VIDEO SHOWING THE PROBLEM https://youtu.be/uWlSUxxMy08 AND https://youtu.be/iUW3Z2u3IDs UPDATED ENTIRE RELATED FILES: https://drive.g...
[27 replies] Last: 2010 doesn't support the latest C/C++ standards. *PTUI!* Actually it... (by thmm)
Is the curiosly recurring template pattern recursive?
 
Hi, In this definition: template<typename T> struct ordered { bool operator>(T const& rhs) const { // locate full derived object T const& s...
[5 replies] Last: no, it does compiles because of your weird bogus -> ordered<Int> inh... (by ne555)
how do you find the median in c++
 
from smallest to largest this is what I have if(grades < grades && grades < grades && grades < grades && grades < grades ) { cout<<grad...
[1 reply] : Yes, there's a general-purpose sort: https://www.cplusplus.com/referen... (by lastchance)
get index of smallest number of array
 
hello I'm trying to get the index of the smallest element of an array, IF this element index satisfies a condition in another array. explaining: i have an int...
[3 replies] Last: hey guys. I'm using it to choose positions for buildings in a grid. th... (by Stauricus)
No matching constructor for initialization error
 
//header file with constructor initialization within the StudentClub class class StudentClub { public: StudentClub(Student* p, Student* v, Stud...
[3 replies] Last: I this homework where you need to do things in a certain way ? If not ... (by thmm)
by frek
Simple bit set example
 
In this piece of code: #include <iostream> template<typename T> void print(T t) { std::cout << t << ' '; } int main() { int si = 128; // doesn’t fit int...
[3 replies] Last: ... (by seeplus)
by frek
Text editor for socket programming
 
I'm about starting learning C++ socket programming. For that a compiler like GCC and an OS like Ubuntu are appropriate to get started I guess. But I also need a...
[4 replies] Last: Twice have I had application that needs to transfer data. First time w... (by keskiverto)
February 2022 Pages: 12345
  Archived months: [jan2022] [mar2022]

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