
C++
Evildoer_llc
这个作者很懒,什么都没留下…
展开
-
C++中的引用和const
引用(&) 引用是将一个变量声明为另一个变量的别名 int rats; int &rodents = rats; 引用必须在声明变量时就进行初始化,而不能像指针那样,先声明,后初始化 #pragma GCC optimize(2) #include<bits/stdc++.h> using namespace std; int main() { //fr...原创 2019-09-20 19:29:44 · 302 阅读 · 0 评论 -
继承与派生
class TablePlayers { private: string firstname; string lastname; bool hasTable; public: TablePlayers(const string &fn = "none", const string &ln = "none", bool ht = false); void name()co...原创 2019-10-02 23:28:05 · 293 阅读 · 0 评论 -
STL迭代器异常 map,set的erase()和insert()操作
我们都知道在STL中有迭代器,但是erase()和insert()操作会使迭代器异常 erase()会删除迭代器 例如: set<int>st; set<int>::iterator it = st.begin() for(it;it!=st.end();it++) { erase(*it); } 我们通常会这样来删除set中的元素,但是这样删除的话,会把...原创 2019-10-08 23:17:00 · 807 阅读 · 0 评论 -
#ifndef与#endif与Static
#ifndef与#endif #ifndef A #define A ... ... #endif 在同一个文件中只能讲同一个头文件包含一次。 使用这种技术为了将文件内容包含在#ifndef中 就是说如果编译器第一次碰到A的定义,则会查看ifndef到endif之间的内容,并读取A定义这一行 如果在同一个文件中遇到包含该文件的代码,则直接跳到endif后面的一行上。 注意:这种方...原创 2019-10-09 22:52:56 · 414 阅读 · 0 评论 -
new与malloc区别
博客转载:https://blog.youkuaiyun.com/z735640642/article/details/88047938转载 2019-10-10 23:35:07 · 205 阅读 · 0 评论