c++基础
文章平均质量分 76
UID_平常心
这个作者很懒,什么都没留下…
展开
-
指针、引用为函数参数传值
//指针、引用作为函数参数传值 #include using namespace std; void SwapVarPoint(int *p1, int *p2); void SwapVarReference(int& r1, int& r2); void main() { int a=1; int b=2; cout SwapVarPoint(&a,&b); co原创 2013-05-14 12:33:21 · 475 阅读 · 0 评论 -
带AI功能的3x3画井字游戏(指针版本)
// Tic-Tac-Toe 2.0 // Plays the game of tic-tac-toe against a human opponent // Uses pointers instead of refernces for function parameters #include #include #include #include using原创 2013-05-16 08:54:45 · 878 阅读 · 0 评论 -
对指针、引用的理解(一)
// Inventory Pointer // Demonstrates returning a pointer #include #include #include using namespace std; int main() { int a=10; int& b=a;//别名 int *c=&b;//指向b就是指向a cout c原创 2013-05-16 08:51:39 · 429 阅读 · 0 评论 -
一个单词猜词程序
// Word Jumble // The classic word jumble game where the player can ask for a hint #include #include #include #include using namespace std; int main() { enum fields {WORD, HIN原创 2013-05-09 14:40:44 · 679 阅读 · 0 评论 -
虚函数与调用和重写基类成员函数
//Overriding Boss //Demonstrates calling and overriding base member functions #include using namespace std; class Enemy { public: Enemy(int damage = 10); void virtual Taunt() cons原创 2013-05-22 22:17:05 · 1593 阅读 · 0 评论 -
虚函数与多态
//Polymorphic Bad Guy //Demonstrates calling member functions dynamically #include using namespace std; class Enemy { public: Enemy(int damage = 10); virtual ~Enemy(); void virtu原创 2013-05-22 22:36:23 · 540 阅读 · 0 评论 -
关于C++函数指针、函数回调的相关总结(重载与多态)
#include using namespace std; void PrintPass (int nScore) { cout } void PrintFailed (int nScore) { cout } void PrintExcellent (int nScore) { cout } /*int main() { int nScore=22;原创 2013-05-07 22:16:08 · 611 阅读 · 0 评论 -
一个动物类的小游戏【类和对象】
//Critter Caretaker //Simulates caring for a virtual pet #include using namespace std; class Critter { public: Critter(int hunger = 0, int boredom = 0); void Talk(); void Eat(int foo原创 2013-05-18 12:41:57 · 507 阅读 · 0 评论 -
带AI功能的3x3画井字游戏(引用版本)
#include #include #include #include using namespace std; // global constants const char X = 'X'; const char O = 'O'; const char EMPTY = ' '; const char TIE = 'T'; const char NO_O原创 2013-05-09 21:36:44 · 1046 阅读 · 3 评论 -
对指针、引用的理解(三)【引用】
// Inventory Referencer // Demonstrates returning a reference #include #include #include using namespace std; //returns a reference to a string string& refToElement(vector& inven原创 2013-05-16 11:05:55 · 440 阅读 · 0 评论 -
对指针、引用的理解(二)【指针】
//Inventory Pointer // Demonstrates returning a pointer #include #include #include using namespace std; //returns a pointer to a string element string* ptrToElement(vector* const pVe原创 2013-05-16 09:18:59 · 542 阅读 · 0 评论