Time of Update: 2018-12-04
學習C++ STL的目的不是讓我們的編程更複雜,而是讓我們的編程更簡單,比如要實現C++ string類型的字串字元替換功能就可以用到一個很強大的函數replace,它的文法聲明如下:template<caass FwdIt, class T> void replace(FwdIt first, FwdIt last, const T& vold, const T& vnew);要使用這個函數,首先我們得引入標頭檔,如下:#include <
Time of Update: 2018-12-04
下面是對類中static變數的一點講解 =============================================== 待用資料成員的使用方法和注意事項如下: 1、待用資料成員在定義或說明時前面加關鍵字static。 2、靜態成員初始化與一般資料成員初始化不同。待用資料成員初始化的格式如下: <資料類型><類名>::<待用資料成員名>=<值>
Time of Update: 2018-12-04
從學習C語言開始,已經接觸這門語言好幾年了,不敢說有多精通,本文就本人以往遇到過的幾個問題做一個說明。1、認識C語言的安全隱患。 首先,我們來看一個簡單的例子。 int nData = 50;char szBuf[20]; memset(szBuf,0,20);strcpy(szBuf,(const
Time of Update: 2018-12-04
1 基本解釋 extern可以置於變數或者函數前,以標示變數或者函數的定義在別的檔案中,提示編譯器遇到此變數和函數時在其他模組中尋找其定義。 另外,extern也可用來進行連結指定。2 問題:extern 變數 在一個源檔案裡定義了一個數組: char a[6]; 在另外一個檔案裡用下列語句進行了聲明: extern char *a; 請問,這樣可以嗎? 答案與分析: 1)、不可以,程式運行時會告訴你非法訪問。原因在於,指向類型T的指標並不等價於類型T的數組。
Time of Update: 2018-12-04
A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced. class SimpleClass{
Time of Update: 2018-12-04
All unary and binary operators have pre-defined implementations, that are automatically available in any expressions. In addition to this pre-defined implementations, user defined implementations can also be introduced in C#. The mechanism of giving
Time of Update: 2018-12-04
先看這麼個問題——已知:class CBase{ int a; char
Time of Update: 2018-12-04
使用floor函數。floor(x)返回的是小於或等於x的最大整數。如: floor(10.5) == 10 floor(-10.5) == -11使用ceil函數。ceil(x)返回的是大於x的最小整數。如: ceil(10.5) == 11 ceil(-10.5) ==-10 floor()是向負無窮大舍入,floor(-10.5) == -11;ceil()是向正無窮大舍入,ceil(-10.5) == -10 fix朝零方向取整,如fix(-1.3)=-
Time of Update: 2018-12-04
C. About Bacteriatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputQwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some
Time of Update: 2018-12-04
c++編程思想用的是最新的兩卷合訂版本。所以提到的頁碼與該書對應。第一卷的16章和第二卷的第五章講模板。前者比較基礎。後者幾乎包括了模板的所有東西。本書與c++ primer的不同之處,就是講解得比較有連續性,都有完整原始碼。而c++
Time of Update: 2018-12-04
//模板開始#include <string> #include <vector> #include <algorithm> #include <iostream> #include <sstream> #include <fstream> #include <map> #include <set> #include <cstdio> #include
Time of Update: 2018-12-04
#include <map>#include <cmath>#include <cstdio>#include <vector>#include <string>#include <cstdlib>#include <cstring>#include <sstream>#include <fstream>#include <iostream>#include
Time of Update: 2018-12-04
內嵌函式的學習。#include<iostream>#include<string>#include<fstream>using namespace std;#define f(x) (x+1)#define floor(x,b) ((x)>=(b)?0:1)// 加括弧的好處#define band(x) ((x)>5&&(x)<10 ? (x):0)inline int plusOne(int x) {return
Time of Update: 2018-12-04
#include<iostream>using namespace std;/*--------------------static 學習-------*/int x=100;class withStatic {int i;static int x;static int y;public:void print() const {cout<<"x= : "<<x<<endl;cout<<"y= :
Time of Update: 2018-12-04
這一節分析下具體實體類的定義和實現,下面是這個遊戲的實體類結構: 遊戲物體的運動就是不斷建立畫面和銷毀畫面的過程,原理和播放錄象帶一樣。所以我定義了一個基類,裡面定義了子類共同的成員,由於方法具體實現都一樣,所以在基類裡的Draw和Crear方法並沒有定義為抽象方法,反而具體實現了它們!子類繼承後就不需要具體實現了。CommonMethod.cs/// <summary> /// 這裡定義了一些蛇類和食物類中共同用到的函數和基本屬性資料,供子類繼承 ///
Time of Update: 2018-12-04
今天寫了一個類似這樣的程式:#include <stdio.h>#include <string.h>int main(){ int i = -1; if(i > strlen("Demon")) printf("Hello World"); else printf("Hello Demon"); return 0;}輸出的竟然是Hello World!-1 >
Time of Update: 2018-12-04
遊戲如果沒有存檔,每次都從零開始,那將會很沒意思。為了提高遊戲的可玩性,我這裡添加了資訊的存取功能,主要包括遊戲積分、遊戲角色的存取和熱門排行榜,這樣每次開啟遊戲就可以看到最高分者!這樣才有挑戰性,挑戰最高分並把你的大名記錄在英雄榜上! 我用積分;玩家- 格式儲存遊戲資訊在本地磁碟的記事本上 @"D:/SnakeGameInfo.txt";這樣啟動遊戲後便可以讀取和儲存資訊了。 並按積分高低排列英雄榜: SaveGameInfo.cs public
Time of Update: 2018-12-04
/*---------------------------------------------------------------------------------------------- 時隔很久又想到csdn部落格了,心血來潮想發表幾篇毫無技術含量的文章,請務必相信我,絕對沒有任何技術可言,都是胡思亂想毫無“標準”的“亂作”!管它呢,代碼寫得再差也是自己的事,自己能寫出點小玩意高興就行了,對吧!
Time of Update: 2018-12-04
Q:c#GDI+繪製透明控制項。refer:http://bbs.csdn.net/topics/390541413A:public class TransparentControl : UserControl{ public TransparentControl() { BackColor = Color.Transparent; Paint += new PaintEventHandler(TransparentRender); }
Time of Update: 2018-12-04
Q:對一個Bitmap進行Alpha混合。refer:http://bbs.csdn.net/topics/390539448A:public void AlphaBlend(Bitmap source, byte alpha, Color backColor){ for (int x = 0; x < source.Width; x++) { for (int y = 0; y < source.Height; y++) { Color sc =