2-2. Initializing Objects with Initializer Lists

Using Uniform Initialization to Construct a vector

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    using MyVector = vector<int>;
    MyVector vectorA( 1 );
    cout << vectorA.size() << " " << vectorA[0] << endl;
    MyVector vectorB( 1, 10 );
    cout << vectorB.size() << " " << vectorB[0] << endl;
    MyVector vectorC{ 1, 10 };
    cout << vectorC.size() << " " << vectorC[0] << endl;
    return 0;
}

1.使用Uniform Initialization可以使得初始化比较方便。

2.using的使用也比较陌生

时间: 2024-12-29 11:25:04

2-2. Initializing Objects with Initializer Lists的相关文章

Modern C++ CHAPTER 2(读书笔记)

CHAPTER 2 Recipe 2-1. Initializing Variables Recipe 2-2. Initializing Objects with Initializer Lists 使用初始化列表的使用 Recipe 2-3. Using Type Deduction 关于auto关键字的使用 Recipe 2-4. Using auto with Functions Recipe 2-5. Working with Compile Time Constants conste

iOS -- warnings

Semantic Warnings Warning Message -WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8 -WNSObject-attribute         __attribute ((NSObject)) may be put on a typedef only, attribute is ignore

IOS 警告 收集

Semantic Warnings Warning Message -WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8 -WNSObject-attribute __attribute ((NSObject)) may be put on a typedef only, attribute is ignored -Wabst

Ten C++11 Features Every C++ Developer Should Use

原版:http://www.codeproject.com/Articles/570638/Ten-Cplusplus-Features-Every-Cplusplus-Developer 译版:http://blogs.ejb.cc/archives/7190/top-10-new-features-you-should-know-about-c-11 This article discusses a series of features new to C++11 that all devel

IOS 警告 汇总

Semantic Warnings Warning Message -WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8 -WNSObject-attribute __attribute ((NSObject)) may be put on a typedef only, attribute is ignored -Wabst

iOS编程 手动忽略clang编译器警告

在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak.循环引用.不能运行之类的警告. 有代码洁癖的孩子们非常想消除他们, 今天就让我们来一次Fuck 警告.! 首先学会主要的语句 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" 这里写出现警告的代码 #pragma clang diagnostic pop 这样就消除了方法弃用的警告. 同理,

Google C++ 代码规范

Google C++ Style Guide Table of Contents Header Files Self-contained Headers The #define Guard Forward Declarations Inline Functions Names and Order of Includes Scoping Namespaces Unnamed Namespaces and Static Variables Nonmember, Static Member, and

iOS:消除项目中警告

引言: 在iOS开发过程中, 我们可能会碰到一些系统方法弃用, weak.循环引用.不能执行之类的警告. 有代码洁癖的孩子们很想消除他们, 今天就让我们来一次Fuck 警告!! 首先学会基本的语句: #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" 中间这里写出现警告的代码 #pragma clang diagnostic pop 这样就消除了方法弃用的警

ios deprecated 警告消除 强迫症的选择

#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" 这里写出现警告的代码 #pragma clang diagnostic pop 这样就消除了方法弃用的警告! 同理, 大家可以在下边搜索到对应的警告, 这样 就可以把前边的字串填入上边的ignored的后边, 然后阔住你的代码, 就OK了 源网址 原文对应的警告: Semantic Warnings War