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 are the application skills of C++ standard extension

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what is the application skill of C++ standard extension". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Today experiment C++ standard extensions in the use of shared_ptr, the results in gcc4.1 how also compiled in the past, check the Internet, but also downloaded the TR1 manual. Finally, I understand that you have to add it to #include

#include

< tr1/memory>

#include

< iostream>

#include

< string>

#include

< tr1/array>

#include

< tr1/memory>

using namespace std;

using std::tr1::shared_ptr;

class Widget

{

public:

Widget()

{

pstr = new string("Hello world! ");

cout

< < "Widget's construction is called" < < endl; } Widget(const Widget& rhs) { cout < < "Widget's copy construction is called" < < endl; } Widget& operator=(const Widget& rhs) { return *this; } ~Widget() { delete pstr; cout < < "Destruction is called" < < endl; } private: string* pstr; }; int main() { auto_ptr< Widget>

pInv(new Widget);

auto_ptr

< Widget>

pInv2(pInv);

shared_ptr

< Widget>

pInvN(new Widget);

array

< int, 5>

a = {{1,2,3,4,5}};

cout < < a[3] < < endl;

return 0;

}

This file. Hehe, maybe I was too careless! The C++ standard extension, according to TR1, mainly includes:

Reference Wrappers Shared_ptr result_of mem_fn Function Object Binders Polymorphic Function Wrappers Type Traits Random Numbers Tuples Array Hash Functions Regular Expressions Complex Number Algorithms

These C++ standard extensions, we see the long-awaited regular expressions are also here Oh!

"C++ standard extension application skills is what" the content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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