Skip to main content

All Questions

Tagged with
0 votes
0 answers
45 views

What would be a better way to deal with a ifstreams failed state in this code?

I was reading Bjarne Stroustrup's "Principle and Practice using C++". Chapter 10.6 is about error handling of iostreams. He highlights that you should always try to recover from a fail() ...
user3612's user avatar
  • 353
-8 votes
1 answer
101 views

Have I missed something? [closed]

I'm just writing some quick number guessing game code, but I keep running into the "Expected Unqualified id" error. I've checked all the semicolons, but maybe I've missed something? Here's ...
it-follows's user avatar
1 vote
2 answers
81 views

C++ nullpointer dereference when adding instance to std::map within the constructor

I am trying to get an error-code list for my C++ application, so that errors are shared across multiple projects. Each error contains simply a unique code (to give to exit() and similars) and a ...
Romolo Caponera's user avatar
4 votes
0 answers
89 views

benchmarking exceptions vs error by value

I've decided to measure the performance difference between 2 approaches for handling errors: return by value (sum of errors) throw I've written a simple benchmark for calculating a sum of a large ...
Sergey Kolesnik's user avatar
1 vote
1 answer
140 views

How to guarantee the existence of a std::chrono::tzdb at program startup?

Is there a way to determine whether or not a timezone database is initialized at the start of a program? My aim is to not have a std::runtime_error thrown mid program because of a non-existent tzdb. I ...
digito_evo's user avatar
  • 3,582
0 votes
0 answers
67 views

Proper way of handling c++ library resource/context management

In the context of cpp-code interacting with a c libraries, I come across the following types of functions. AcquireResource, ReleaseResource GetList, SubmitList open, close Initialize, Finalize Or in ...
Sam Coutteau's user avatar
0 votes
0 answers
38 views

Where in the source code is the class function, and how do I remedy the error message?

I'm trying to build a program from a source code. The following error message appears during the make step: error: no 'bool CScript::IsPushOnly() const' member function declared in class 'CScript'. ...
SpiritTiger's user avatar
-1 votes
2 answers
93 views

Boolean testing vs exception in stringstream [closed]

I want to short-circuit when an I/O operation on a std::istringstream/std::ostringstream fails, to avoid unnecessarily calling the rest of any chained <</>> operators on the already failed ...
digito_evo's user avatar
  • 3,582
0 votes
1 answer
44 views

Overloaded function not outputting correct answer

I am attempting to create an overloaded contructor that will take in integer and add them with the byteAdd function. However; whenever I compile the output is always the default constructor rather ...
Steven Osi's user avatar
0 votes
0 answers
44 views

No suitable conversion function [duplicate]

I am currently working on a menu that, when the user inputs the corresponding number, the menu will connect and use that function. These functions are arithmetic (add, subtract, multiply, and divide). ...
Steven Osi's user avatar
0 votes
1 answer
72 views

How to handle an error when loading a picture into a TImage component?

I am using a VCL TImage component to load a picture from a file in Embarcadero C++Builder 11.3. "pic.bmp" is a valid picture: Image1->Picture->LoadFromFile("C:\\SomePath\\pic.bmp&...
Dex's user avatar
  • 13
0 votes
0 answers
65 views

ERROR with "SFML/Graphics.hpp' file not found"

I ran into an error in X Code for the library when every I was using the #include SFML/Graphics.hpp however it said the file was not found enter image description here I even imported the libraries ...
AXB2028's user avatar
0 votes
2 answers
749 views

Warning of installing redistrubatble in Visual Studio 2015

I got a new computer and had to reinstall Visual Studio 2015 on it. Most of the time it went okay till the end. I got these warnings: Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.24210 : ...
pmb88's user avatar
  • 147
2 votes
1 answer
327 views

How to ensure a string is a valid filename/path?

What is the most appropriate way of ensuring that a string (user input) is a valid text file path? And also the extension part should be either .txt or empty. I have considered two approaches: const ...
digito_evo's user avatar
  • 3,582
1 vote
0 answers
128 views

What Windows system error codes can GetCurrentDirectory() set, and how to interpret them?

I'm trying to implement error handlers for possible Windows system errors that the GetCurrentDirectory() function might set to the last-error code. The documentation only says: If the function fails, ...
ridilculous's user avatar

15 30 50 per page
1
2 3 4 5
66