C++编程总结

    xiaoxiao2021-03-26  27

    1 stringsteam重复使用同一string

    while (std::getline(files_stream, line)) { std::istringstream ss(line); string s; vector<string> line_buf; while (ss >> s) line_buf.push_back(s);// 这里取出一行string的所有小string ss.clear(); ss.str(line); string name1, name2; int id1, id2; if (line_buf.size() == 3) { ss >> name1 >> id1 >> id2;// 再次使用line这一string } else if (line_buf.size() == 4) { ss >> name1 >> id1 >> name2 >> id2; } }

    2 修饰符*& int *& a = ….. a是指针的引用,a发生变化对应的指针也同时发生变化

    3 引用与指针转换 int a = 0; int &b = a; int *c = &b;

    这里c指向a

    转载请注明原文地址: https://ju.6miu.com/read-663993.html

    最新回复(0)