摘要: 1.C++ string int main() { //1.string初始化方式 //构造空的 string str; cout << str.size() <<"\t"<< str.length() << endl; // 0 0 //构造方式初始化 string str1 ("ILoveYou 阅读全文
posted @ 2021-09-03 23:30 Creature_lurk 阅读(37) 评论(0) 推荐(0)
摘要: 1.结构体基本区别 struct MM { char name[20]; int age; void print() //默认为内联函数 { cout << name << "\t" << age << endl; } }; int main() { //1.定义变量时省略关键字 struct MM 阅读全文
posted @ 2021-09-03 22:15 Creature_lurk 阅读(40) 评论(0) 推荐(0)
摘要: 1.类型推断 int Max(int a, int b) { return a > b ? a : b; } //错误,没有推断依据 //auto Max(auto a, auto b) //{ // return a > b ? a : b; //} int main() { //常量 auto 阅读全文
posted @ 2021-09-03 20:45 Creature_lurk 阅读(61) 评论(0) 推荐(0)
摘要: 1.new和delete基本用法 new用来申请内存,delete用来释放内存 int main() { int* p = new int; delete p; p = nullptr; int* pp = new int[4]; delete []pp; pp = nullptr; //申请内存并 阅读全文
posted @ 2021-09-03 19:26 Creature_lurk 阅读(48) 评论(0) 推荐(0)