পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Saturday, January 28, 2017

C++ Library -

Introduction

It is a standard exception class. All objects thrown by components of the standard library are derived from this class. Therefore, all standard exceptions can be caught by catching this type by reference.

Declaration

Following is the declaration for std::exception.
class exception;

Example

In below example for std::exception.
#include <thread>
#include <vector>
#include <iostream>
#include <atomic>
 
std::atomic_flag lock = ATOMIC_FLAG_INIT;
 
void f(int n) {
   for (int cnt = 0; cnt < 100; ++cnt) {
      while (lock.test_and_set(std::memory_order_acquire))
         ;
      std::cout << "Output from thread " << n << '\n';
      lock.clear(std::memory_order_release);
   }
}
 
int main() {
   std::vector<std::thread> v;
   for (int n = 0; n < 10; ++n) {
      v.emplace_back(f, n);
   }
   for (auto& t : v) {
      t.join();
   }
}

Derived types

S.N. Derived types Definition
1 bad_alloc This exception thrown on failure allocating memory
2 bad_cast This exception thrown on failure to dynamic cast
3 bad_exception This an exception thrown by unexpected handler
3 bad_function_call This exception thrown on bad call
4 bad_typeid This exception thrown on typeid of null pointer
5 bad_weak_ptr It is a bad weak pointer
6 ios_base::failure It is a base class for stream exceptions
7 logic_error It is a logic error exception
8 runtime_error It is a runtime error exception

Derived types(through logic_error)

S.N. Derived types Definition
1 domain_error It is a domain error exception
2 future_error It is a future error exception
3 invalid_argument It is an invalid argument exception
4 length_error It is a length error exception
5 out_of_range It is a out-of-range exception

Derived types(through runtime_error)

S.N. Derived types Definition
1 overflow_error It is an overflow error exception
2 range_error It is a range error exception
3 system_error It is a system error exception
4 underflow_error It is a underflow error exception

Derived types(through bad_alloc)

S.N. Derived types Definition
1 bad_array_new_length It is an exception on bad array length

Derived types(through system_error, since C++11)

S.N. Derived types Definition
1 ios_base::failure It is a base class for stream exceptions

Member functions

S.N. Derived types Definition
1 (constructor) It is constructor exception
2 operator= It is a copy exception
3 what It is used to get string identifying exception
4 (destructor) It is a destroy exception

No comments:

Post a Comment