Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the way exceptions are passed on C++?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "what is the way of exception transmission in C++". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what is the way of exception transmission in C++" can help you solve the problem.

1. Abnormal transmission of C++. Pass value (by value)

In the process of passing values, there will be a copy of temporary objects, which can not solve the problem of polymorphism, as follows: myexception inherits exception, but can not be correctly called the method of myexception, resulting in the cutting of abnormal objects.

Class myexception:public exception {public: virtual const char* what () throw (); const char* myexception::what () {return "myException";} class A {public: a () {} void f () throw () {throw myexception ();}}; int main () {An a; try {a.f ();} catch (exception exc) {cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report