Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Jump initializer_list in Clipper 11

Shulou Source: shulou.com Published: 2022-06-01 01:23:13 09月19日 Update

This article introduces the relevant knowledge of "how to achieve jump initializer_list in Clipper 11". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Implementation of initialization list

(1) when the compiler sees {T1 # T2 … When tn}, an initializer_list object is generated (where T is the type of the element), which is associated with an array.

(2) for the aggregation type, the compiler will decompose the elements in the array one by one and assign values to the initialized object. This is equivalent to assigning a separate value to each field of the object.

(3) for non-aggregate types. If the class has a constructor that accepts the initializer_list type, the initializer_list object is passed to the constructor as a whole during initialization. If no such constructor exists, the elements in the array will be decomposed by the compiler and passed to the corresponding constructor that accepts these parameters (for example, if there are two elements in the list, they will be passed to the constructor with two arguments. If there are three elements, pass it to the constructor with three arguments, and so on. ).

[case study] the first experience of initializer_list

# include # include using namespace std;// compilation option: public +-std=c++11 test1.cpp-fno-elide-constructorsclass Foo {public: Foo (int) {cout

Tags: Function element compilation type object compiler parameter copy container build two number content address field instance parenthesis whole more template Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker OPPO Reno Shulou Information Shulou Technology