Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Beginning C++ Programming

You're reading from   Beginning C++ Programming Modern C++ at your fingertips!

Arrow left icon
Product type Paperback
Published in Apr 2017
Publisher Packt
ISBN-13 9781787124943
Length 526 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Richard Grimes Richard Grimes
Author Profile Icon Richard Grimes
Richard Grimes
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Starting with C++ FREE CHAPTER 2. Understanding Language Features 3. Exploring C++ Types 4. Working with Memory, Arrays, and Pointers 5. Using Functions 6. Classes 7. Introduction to Object-Orientated Programming 8. Using the Standard Library Containers 9. Using Strings 10. Diagnostics and Debugging

Using classes

The Resource Acquisition Is Initialization technique is useful for managing resources provided by other libraries, such as the C Runtime Library or the Windows SDK. It simplifies your code because you do not have to think about where a resource handle will go out of scope and provide clean-up code at every point. If the clean-up code is complicated, it is typical in C code to see it put at the end of a function and every exit point in the function will have a goto jump to that code. This results in messy code. In this example, we will wrap the C files functions with a class, so that the lifetime of the file handle is maintained automatically.

The C runtime _findfirst and _findnext functions allow you to search for a file or directory that matches a pattern (including wildcard symbols). The _findfirst function returns an intptr_t, which is relevant to just that search...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime