
C++
JasonDecode
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
c++ 编译多个c++文件
38 compile many files header file:declaration : .h, have struct and function name implementation file, .cpp, inside cpp must include header file, only have function main file: calling, .cpp inside cpp must include header file, only have main // file原创 2020-12-15 15:41:06 · 355 阅读 · 0 评论 -
c++ overloading
#include <iostream> #include <vector> #include <string> void swap(int &a, int &b) { int temp = a; a = b; b = temp; std::cout << "a: " << a << "\tb: " << b << "\n"; } void swap(std::string &a原创 2020-12-15 14:45:24 · 183 阅读 · 0 评论 -
c++ 文件操作
// open a new file #include <iostream> #include <fstream> int main() { std::ofstream file; file.open("hello.txt"); // open an new file file << "hey"; // write into file file.close(); return 0; } // file write replace all conte原创 2020-12-15 11:00:59 · 109 阅读 · 0 评论 -
c++: 29 templatized array
#include <iostream> #include<array> void print_vector(std::array<int, 20> data, int size) { for(int i = 0; i < size; i++) { std::cout << data[i] << "\t"; } std::cout << "\n"; } int main() { std::原创 2020-12-14 20:44:42 · 113 阅读 · 0 评论 -
c++ vectors passing by reference or value
28 vectors dynamic size, like list std::vector items = {1, 2, 3} items.push_back(100) reallocate memory if not enough to store items.size() items[items.size() - 1] #include <iostream> #include<vector> int main() { std::vector<int> da原创 2020-12-14 20:11:28 · 141 阅读 · 0 评论 -
c++ - do while and array and functions
21 do while #include <iostream> #include <string> int main() { std::string password = "123"; std::string guess; do // guess at least one time { std::cout << "Guess the password: "; std::cin >> guess; } whi原创 2020-12-14 19:23:58 · 119 阅读 · 0 评论 -
c++: create a manu and guessing game
24 create a manu #include <iostream> #include <string> int main() { int choice; do { std::cout << "0. Quit" << std::endl << "1. Play Game\n"; std::cin >> choice; switch(choice)原创 2020-12-14 16:54:17 · 173 阅读 · 0 评论 -
c++ - break and continue用法
22 break and continue #include <iostream> #include <string> int main() { std::string sentence = "Hello my name is Jim"; for(int i = 0; i < sentence.size(); i++) { std::cout << sentence[i] << std::endl; if(sen原创 2020-12-14 16:18:13 · 117 阅读 · 0 评论 -
c++ do while用法
21 do while #include <iostream> #include <string> int main() { std::string password = "123"; std::string guess; do // guess at least one time { std::cout << "Guess the password: "; std::cin >> guess; } whi原创 2020-12-14 16:04:00 · 1089 阅读 · 0 评论 -
C++ -string method - find, replace, size, append
#include<iostream.h> #include<string> int main() // main function { std::string greeting = "Hello"; // empty string: "" greeting += "!"; // string method cout << greeting[5] << endl; // ! cout << greeting.length() <&l原创 2020-12-14 09:56:01 · 197 阅读 · 0 评论 -
C++入门基础
C++ C++ characteristics vector list, forward_list(singly-linked list), … map, unordered_map(hash table), … set, multi_set, … string thread memory management C++ compilation + linking OOP safe programming superset of C case sensitive 1 Hello world! prin原创 2020-12-13 21:19:42 · 153 阅读 · 0 评论