02 2012 档案

摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _8下拉列表{ public partial class Form1 : Form { public Form1() { InitializeComponent();... 阅读全文
posted @ 2012-02-27 23:24 简单--生活 阅读(208) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;/* 登际界面,登陆错误三次退出程序,假设用户名,密码是admin 888888, 不区分大小写 * (易错点: 局部变量与类变量的使用) * 退出程序this.Close() 或者 Application.Exit(); * * 修改密码,界面上 阅读全文
posted @ 2012-02-27 23:23 简单--生活 阅读(180) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _7练习6{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ... 阅读全文
posted @ 2012-02-27 23:22 简单--生活 阅读(160) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _4练习2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ... 阅读全文
posted @ 2012-02-27 23:21 简单--生活 阅读(141) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _6练习4{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ... 阅读全文
posted @ 2012-02-27 23:21 简单--生活 阅读(148) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _3练习1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); ... 阅读全文
posted @ 2012-02-27 23:20 简单--生活 阅读(210) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;/* 第一个Windows程序 * WinForm: Windows Form, .Net中用来开发windows窗口程序的技术,无论是之前学的控制台程序,还是后面学的ASP.Net都是调用.Net框架,因此所有知识点都是一样的 * 新建一个WIn 阅读全文
posted @ 2012-02-27 23:19 简单--生活 阅读(219) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace _2计算器练习{ public partial class Form1 : Form { public Form1() { InitializeComponent()... 阅读全文
posted @ 2012-02-27 23:19 简单--生活 阅读(205) 评论(0) 推荐(0) 编辑
摘要:jQuery提供簡單易用的DOM操作能力,讓我們可以專注於Javascript程式的邏輯而不用去理會煩人的DOM操作、瀏覽器相容等問題。我們可以利用next()來取得同級的下一個元素,利用prev()來取得同級的上一個元素,但是jQuery並無直接由函數提供取得同級的第一個元素、同級的最後一個元素、同級的任一元素,因此我們可以利用jQuery強大的Selector(選擇器)達成這樣的需求,並替jQuery擴充功能。擴充jQuery的功能函數,把以下程式碼加入JQuery中view plaincopy to clipboardprint?//取得第一個同級元素$.fn.first=functio 阅读全文
posted @ 2012-02-27 12:00 简单--生活 阅读(1513) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using _16命名空间.hr;using System.Collections; //如果要使用的类和当前的类不在同一个namespace中,则需要using引用的//using _Person;/* 命名空间 * namespace(命名空间),用于解决类重名问题,可以看做是"类的文件夹" * 在代码中使用其他类的时候需要using类所在的namespace. System.Collections.Arra 阅读全文
posted @ 2012-02-26 13:35 简单--生活 阅读(230) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 常量与静态成员 * const常量,常量名要大写 * 不用new就能用的方法: static方法,static方法其实就是普通的函数 * 在static方法中可以调用其他static方法,字段,属性,但不能调用非static方法,字段,属性,在非static方法可可以调用static的方法,字段 * * */namespace _14常量{ class Program { public const ... 阅读全文
posted @ 2012-02-26 11:13 简单--生活 阅读(208) 评论(0) 推荐(0) 编辑
摘要:using System;/* 异常异常处理 * 传统的错误表达方式: 错误码,举列 * 错误码的缺点:不处理的则很难发现,每次处理则很麻烦,难以看出错误的原因,容易使得程序进入不确定的状态 * try catch Exception ex异常也是对像 * Exception类主要属性: Message, StackTrace * 发生异常后程序默认就退出了,后续代码不会被执行了,catch以后的代码则会继承执行 * 不要吃掉异常 * 扔出自己的异常 * */namespace _12异常{ class Program { static void Main(strin... 阅读全文
posted @ 2012-02-25 09:04 简单--生活 阅读(168) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 定义类的时候不指定父类,则父类是Object类,Object类是任何类的直接或者间接父类 * */namespace _10继承{ class Program { static void Main(string[] args) { China c = new China(); c.Age = 22; c.Name = "向... 阅读全文
posted @ 2012-02-25 00:36 简单--生活 阅读(146) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _9对像的引用2{ class Program { static void Main(string[] args) { int i = 10; int j = i; //拷贝 i++; Console.WriteLine(j); //int, datetime,bo... 阅读全文
posted @ 2012-02-25 00:21 简单--生活 阅读(182) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 构造函数 * 构造函数是用来创建对像的特殊函数,函数名和类名一样,没有返回值,连void都不用 * 构造函数可以有参数,new对像的时候传递函数参数即可 * 构造函数可以重载,也就是有我个参数不同的构造函数 * 如果不指定构造函数,则类有一个默认的无参构造函数 * 如果指定了构造函数,则不再有默认的无参构造函数,如果需要无参构造函数,则需要自己来写 */namespace _8构造函数{ class Program ... 阅读全文
posted @ 2012-02-25 00:12 简单--生活 阅读(196) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;//Red Gate's Reflector 反编译工具namespace _5属性2{ class Program { static void Main(string[] args) { //Person5 p = new Person5(); //p.Age = 30; //Console.WriteLine(p.Age);... 阅读全文
posted @ 2012-02-23 23:53 简单--生活 阅读(184) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 面向对像版聊天机器人 * 机器人有不同的名字,维护自己的FullLevel,可以SayHello,可以喂食,可以对它说话(Speak),对异常情况(错误的喂饭数字,喂养的太多撑死了)进行处理,有两个机器人供选择,一开始通过1 2 数字选择聊天机器人 * * */namespace _4练习聊天机器人{ class Program { static void Main(string[] args) ... 阅读全文
posted @ 2012-02-23 23:35 简单--生活 阅读(442) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 属性 * 惯用法,属性开头字母大写,字段开头字母小写 * 只用set或者只有get就可以定义只读或者只写属性(只写的不常见) * 可以为set get设置访问经别 * (.Net3.x)简化set get; public int Age{ get; set; } 适合于set, get 中凤有特殊死搏斗逻辑代码的情况 * * 字段和属性的区别是什么?属性看似字段,不是字段,可以地非法值控制,可以设置只读 * set get块. 阅读全文
posted @ 2012-02-23 22:48 简单--生活 阅读(229) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 成员访问级别 * 字段,方法,属性都可以叫做类的成员,它们都需要定义访问级别,访问级别的用处在于控制成员在哪些些地方可以被访问,这样达到面向对像中"封装"的目的 * * 几个访问级别: public(任何地访都可以访问) private:默认级别,只能由本类中的成员访问 * 还有intemal, protected两个级别,以后会讲 */namespace _2面向对像简介{ class Program { 阅读全文
posted @ 2012-02-23 22:31 简单--生活 阅读(171) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 面向对像概念(*) * 面向对像不是取代面向过程的 * 类,对象。"人"是类,"张三"是"人"这个类的对像,类是抽像的,对象是的,按钮就是类,某个按钮就是对像,对像可以叫做类的实例 * 类就像int, 对像就像10,字段(和类相关的变量),字段就是类的状态,人这个是类的姓名,年龄,身高等字段,类不占内存,对像才占内存 * * 方法,方法就是类能够够执行的动作,比如间好 阅读全文
posted @ 2012-02-23 22:19 简单--生活 阅读(411) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _49_ref_out{ class Program { static void Main(string[] args) { /* 函数的ref out参数 * 函数参数默认的值传递的,也就是"复制一份",例子: * int age = 20; * Int Age(age); ... 阅读全文
posted @ 2012-02-21 23:32 简单--生活 阅读(213) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* * 字符串的处理 */namespace _42字符串基础{ class Program { static void Main(string[] args) { //C#中的单个字符用单引号包含就是char类型,('a'),单引号中放且只能放一个字符 //char a = 'a'; //char b = 'aaa'; ... 阅读全文
posted @ 2012-02-21 00:05 简单--生活 阅读(339) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 函数 * 孙数就是将一堆代码进生重用的一种机制,函数就是一段代码,这段代码可能有输入的值,可能会返回值,一个函数就像一个专门做这件事的人,我们调用它来作一些事情,它可能需要我们提供一些数据给它 * 它执行完成后可能会有一些执行结果给我们,要求的数据就叫参数,返回的执行结果就是返回值 * Console.ReadLine就是一个有返回结果的函数 * Console.WriteLine("Hello")就是一个 阅读全文
posted @ 2012-02-20 22:10 简单--生活 阅读(194) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/*数组 保存多个值,几乎任意类型都可以声明数组 * int[] nums = {5,3,8}; * 个数和声明数必须一致 * int[] nums = new int[3]; * 使用索引器访问指定编号位置的元素,访问数组元素: nums[0],nums[1].索引从0开始,取到元素的类型就是数组元素的类型,可以数组元素进行赋值 * * foreach循环 * string[] names = {"tom",& 阅读全文
posted @ 2012-02-19 23:11 简单--生活 阅读(286) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/*枚举 *确定数量,确定值的几个取值,东西南北,男妇,上中下 * enum Gender{male,female} * enum QQStatus{online, offline, hiden} * 枚举的用法, QQStatus status = QQStatus.online * 和用字符串比下场 来,用格举的好处就是限定了变量的取值范围,程序处理起来更方便 * */namespace _33enum枚举{ enum ... 阅读全文
posted @ 2012-02-19 22:07 简单--生活 阅读(170) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/*类型转换Cast(*) *把源类型赋值给目标型,两个类型不一致的时候会发生类型转换,a=b,b是源,a是目标 *隐式转换,显示式转换,当目标型一定能满足源类型转换过去后的要求的话就是隐式转换,如果当目标类型不一定能满足源类型转换过去后的要求的话就需要显示转换(自己负责) *把中国人转换为人是隐式转换,把人转换为中国人则是显示式转换 *内存中的数据没有变化,只是不同的视角而已 *byte b=1, int i=1, i=b, b= 阅读全文
posted @ 2012-02-19 21:48 简单--生活 阅读(356) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 循环的中断 * break; 立即终站整个循环 * continue; 立即终止当前循环步骤,进行下一次循环步骤 */namespace _22循环的中断{ class Program { static void Main(string[] args) { //练习1:用while continue实现计算1到100之间的除了被7整除之外的所有整数的和 ... 阅读全文
posted @ 2012-02-19 21:21 简单--生活 阅读(253) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* switch case * 类似于if...else....else if....else 但是离散值的判断 * switch一般都可以用if重写,但是if不一定能用switch重写 * 不要忘了break; C#中的break不写是不行的,除了合并case的情况 * * while循环 只要while后小括号中表达式为true,就不执行大括号中的代码 *///15SwitchCase whilenamespace _15S. 阅读全文
posted @ 2012-02-19 18:41 简单--生活 阅读(245) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _12if{ class Program { static void Main(string[] args) { //作业1: 提示用户输入密码,如果密码是"888888"则提示正确,否则提示错误 Console.WriteLine("请输入密码:"); //问题1,用户输入的是非数字的时候失败 ... 阅读全文
posted @ 2012-02-19 18:11 简单--生活 阅读(337) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 布尔运算 * 相等判断: ==, 不要和=混淆 * WriteLine("{0}",i==1); WriteLine("{0}",i=1); 的区别 * 不等判断!= * 大小比较< > <= >= * 取返: ! * 组合运算: && || */namespace _9布尔运算符{ class Program { static void Main 阅读全文
posted @ 2012-02-19 17:23 简单--生活 阅读(214) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 赋值运符=,让左边变量的值等于右边的计算结果,这就能解释令人不解的i = i+1; * (*)+=,-=, *= /= * i2 = i1++; i2=++i1; * */namespace 赋值运算{ class Program { static void Main(string[] args) { //习题: int a = 10; a++; a=a+a; ... 阅读全文
posted @ 2012-02-19 11:42 简单--生活 阅读(258) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 运算符,表达式 * + - * / % * +可以用作字符串连接,其他不可以 * ++ -- * */namespace _7算述运算符{ class Program { static void Main(string[] args) { //让用户输入两个数,打印出两个数的和 /*Console.WriteLine("请输入数值1:"); ... 阅读全文
posted @ 2012-02-19 11:33 简单--生活 阅读(207) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 变量的命名 * 命名规则: 第一个字符必须是字线或者下划线(_),基后的字符可以是任意个数字,字母,下划线 * 不用全部使用C#的关键字,比如class,nameespace,new void 等,判断方式: VS中亮蓝色的就是关键字 * 这也是类,函数等的命名规则 * 中文变量名(类中,函数名) * C#中建义变量开头用小写 * * */namespace _6变量的命名{ class Program { ... 阅读全文
posted @ 2012-02-19 11:22 简单--生活 阅读(198) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* 简单的类型转换 Convert.ToString() ToString() Convert.Toint32(); * */namespace _4Convert类型转换{ class Program { static void Main(string[] args) { Console.WriteLine("请输入第一个字符:"); strin... 阅读全文
posted @ 2012-02-19 11:12 简单--生活 阅读(314) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace _2字符串{ class Program { static void Main(string[] args) { //string s = "\"ab\""; //string s = "a\nb"; //n:newline //string s = "a\\b"; //string s... 阅读全文
posted @ 2012-02-19 11:02 简单--生活 阅读(147) 评论(0) 推荐(0) 编辑
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;/* Virutal studio 是开发工具 * C# 是一种语言C Sharp * .Net Framework是提供函数库类库 * 创建第一个控制台程序并且调试运行 * 为什么要从控制台程序开始? 不要把精力放到表现层,而是把精力放在写代码上, * 无论控制台还是winform还是ASP.net最难的是写代码,而不是拖控件 * 唯一需要学的三条控制台指令,Console.WirteLine:打印输出 * Console.Rea 阅读全文
posted @ 2012-02-19 10:50 简单--生活 阅读(260) 评论(1) 推荐(1) 编辑
摘要://13.7.1 对像指针问题(Object Pointer Problem)//13.7.2 对像指针的外套(The Coat of Object Pointer)//Sony Handle的应用/*#include "createsony.h"#include "sonyhandle.h"#include <iostream>enum{PUREFLAT, PLASMA, LIQUIDCRYSTAL, NANOMETER};void fsh(SonyHandle& sh){sh->adjustVolume();sh->s 阅读全文
posted @ 2012-02-18 23:54 简单--生活 阅读(427) 评论(0) 推荐(0) 编辑
摘要:#include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL,NANOMETER};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps2->adjustLight(); //否则不用 ps2->adjustVolume(); ps2->switchChannel();}void createSonyObject(Create 阅读全文
posted @ 2012-02-18 23:30 简单--生活 阅读(299) 评论(0) 推荐(0) 编辑
摘要://13.6 系统扩展(System Extension)//13.6.1 新添加一个界面(Adding One Interface)//添加一个sony2.h 做为调整亮度的操作,他继承者sony.h//由Sony派生Sony2#include "createsony.h"#include "sony.h"enum Technology{PUREFLAT,PLASMA,LIQUIDCRYSTAL};void fn(Sony* s){ Sony2 * ps2 = dynamic_cast<Sony2*>(s); //增加 if(ps2) ps 阅读全文
posted @ 2012-02-18 22:02 简单--生活 阅读(341) 评论(0) 推荐(0) 编辑
摘要://13.5.1 面向对像的模块(Object-Oriented Module)//13.5.2 Sony类层次结构(Class Sony Hierarchy)//纯平(PureFlat) 等离子(Plasma) 液晶(Liquid Crystal)//例如,若等离子类中有公共操作"等离子图像变换",我们在fn函数中获得了Sony类指针,并确认为等离子29英寸电视机,于是进行以下操作/*void fn(Sony* sp){ B29* b = dynamic_cast<B29*>(sp); if(b) b->切换频道(); //okPlasma* p = d 阅读全文
posted @ 2012-02-18 01:46 简单--生活 阅读(247) 评论(0) 推荐(0) 编辑
摘要://13.4 抽像类做界面(Abstract Class As Interface)//13.4.1 抽像基类方案(The Abstract Base-Class Scheme)//13.4.2 抽像基类IDate(Abstract Base-Class IDate)//我们针Date类的公有成员函数提取出来做成纯虚函数,构成一个抽像类IDate,而Date类则继承之//13.4.3 创建Date对像(Creating Date Objects)//13.4.4 子类Date(Subclass Date)//为了适应抽像类作为界面的形式,Date类应包含idate.h文件,直接继承IDate类 阅读全文
posted @ 2012-02-16 23:23 简单--生活 阅读(257) 评论(0) 推荐(1) 编辑
摘要:$MapString="116.310634759589,39.990045537862,46#116.310371735567,39.989799696735005,44#116.310489333624,39.989904135209,43#116.31047961062,39.989998263946,42.5#116.310506600338,39.990206973256,52.5#116.310506600338,39.990206973256,52.5#116.311968822793,39.99050754819,43#116.312106621229,39.9904 阅读全文
posted @ 2012-02-16 16:36 简单--生活 阅读(361) 评论(0) 推荐(0) 编辑
摘要://在()函数返回一个参考指数禄字符串中的元素。//在()函数比[]操作更安全,因为它不会让你以外的字符串的界限的参考项目。#include <iostream>#include <vector>using namespace std;int main(){ vector<int> v(5,1); //这里访问访问到地址以外的数据信息 /*for(int i=0; i<10; i++){ cout<<"Element "<<i<<" is "<<v[i]<&l 阅读全文
posted @ 2012-02-15 22:53 简单--生活 阅读(157) 评论(0) 推荐(0) 编辑
摘要://用DateMid_New类做界面 ^-^有点不够意思了,这个都还写出来有点错,自己还差点找不到#include "datemid_new.h"#include <iostream>int main(){ DateMid_New d(2005,9,9), e(42211); std::cout<<d; std::cout<<++d<<e; system("pause"); return 0;} //DateMid_New作为应用程序界面#ifndef HEADER_DATEMID_NEW#define H 阅读全文
posted @ 2012-02-15 22:18 简单--生活 阅读(284) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <string>using namespace std;void assign(){ string str="assign"; char str_one='i'; cout<<"size_type num, const char& val\n"; //添加指定数量的字符到str中去 str.assign(6,str_one); cout<<str<<endl; //添加字符串到str中去 string str_two 阅读全文
posted @ 2012-02-15 13:53 简单--生活 阅读(258) 评论(0) 推荐(1) 编辑
摘要://append一共有六种重载类型#include <iostream>#include <string>using namespace std;void append(string& str, int number, char& s){ //cout<<str<<endl; //操把这里的类型弄错了,s只能是只能是字符而不能是string串 str.append(number,s); cout<<str<<endl; //str.append(number,s); string str_one=" 阅读全文
posted @ 2012-02-15 12:25 简单--生活 阅读(406) 评论(0) 推荐(0) 编辑
摘要://日期的天数版本类文件#ifndef HEADER_DATE_TWO#define HEADER_DATE_TWO#include <iostream>using namespace std;class Date_Two{ int absday; int year, month, day;protected: //计算年月日的天数 void ymd2i(int y, int m, int d); static const int tians[]; bool isLeapYear(); //判断是否为闰年public: //构造函数 Date_Two(const string&am 阅读全文
posted @ 2012-02-14 23:25 简单--生活 阅读(490) 评论(0) 推荐(0) 编辑
摘要://历法规定,四年一闰,四百年闰,例如2000年是闰年,2100年不闰年,//公历年份是整百数的,必须是400的倍数的才是闰年,不是400的倍数的就是平年//计算两个日期之间的天数(C++) //定义变量year1, month1, day1, year2, month2, day2//取出2个日期中的年 月 日//如果年相同,月也相同//return day1- day2/*问题: 给你两个日期(如"2010-04-13"和"1988-10-24"),求它们之间相差的天数分析: 这是一年看似简单,实际上却有点复杂的小问题,首先你要考虑到月大月小的问题, 阅读全文
posted @ 2012-02-14 22:12 简单--生活 阅读(24398) 评论(3) 推荐(2) 编辑
摘要://计算两个日期之间的天数(C++)//历法规定,四年一闰,四百年闰,例如2000年是闰年,2100年不闰年,//公历年份是整百数的,必须是400的倍数的才是闰年,不是400的倍数的就是平年//计算天数(C++)#include <iostream>#include <cmath>using namespace std;//判断是否为闰年bool isLeap(int n){ //400的倍数 或者四的倍数是 并且 不是100的倍数,也就是必须不为0 if(n%400==0 || n%4==0 && n%100 !=0) return true; els 阅读全文
posted @ 2012-02-13 23:40 简单--生活 阅读(2159) 评论(0) 推荐(0) 编辑
摘要:"年、月、日"的计算方法是由古代罗马教皇儒咯·恺撒创立的。他在修改太阳历时规定每年有12个月,单月31日,双月30日。这样一年有366日,要比一年应有的365日多一日,因此必须从哪一个月里扣去一日才合适。当时判处死刑的犯人都是在二月份执行处死,人们认为二月份是不吉利的月份,就从二月份中减去了一日,这样,二月只有29日了。后来,恺撒的儿子奥古斯都做了皇帝,他发现自己出生的八月份只有30日,是小月,于是他就又从二月份中减去一日加在八月中,八月变成了有31天的大月,往后的次序也相应改变,九月、十一月改为30天;十月、十二月改为31天,这样二月就只有28天了。这样的变化一 阅读全文
posted @ 2012-02-13 23:36 简单--生活 阅读(15005) 评论(0) 推荐(0) 编辑
摘要://13.3 深度隔离的界面(Deeply Parted interface)//13.3.1 日期的年月日版本(Year-Month-Day of Date VER)//例如,自定义的Date类原先是如下这样定义的//测试一下#include <iostream>#include "date_new.h"using namespace std;int main(){ cout<<"I am Main"; Date_new data(2011,11,11); //cout<<(ostream& o, & 阅读全文
posted @ 2012-02-13 22:37 简单--生活 阅读(440) 评论(0) 推荐(0) 编辑
摘要://13.2 抽像类与体类(Abstract & Concrete Classes)//只要子类中尚有未被覆盖定义的纯虚函数,那么,子类相对于抽像基类的抽像状态不变//该类继承结构由下列程序代码实现之:#include <iostream>class Display{public: virtual void inint()=0; virtual void write(char* pStr)=0;};//定义两个纯虚函数class Monochrome : public Display{ virtual void inint(); //覆盖 virtual void writ 阅读全文
posted @ 2012-02-12 22:28 简单--生活 阅读(560) 评论(0) 推荐(0) 编辑
摘要:#ifndef HEADER_ACCOUNT#define HEADER_ACCOUNT#include<string>using std::string;class Account{ string acntNumber; double balance;public: //构造函数 Account(string _acntNumber, double _balance=0.0); //定义一个虚函数display并定义为const型 virtual void display()const; //定义返回double类型函数getBalance double getBala... 阅读全文
posted @ 2012-02-12 21:50 简单--生活 阅读(344) 评论(0) 推荐(0) 编辑
摘要://A: 操作符重载实现为类成员函数/*#include <iostream>class Person{private: int age;public: Person(int a){ this->age=a; } //inline bool operator==(const Person &ps)const; inline bool operator==(const Person *ps)const;};//inline bool Person::operator==(const Person &ps)const{// std::cout<<&qu 阅读全文
posted @ 2012-02-12 18:19 简单--生活 阅读(999) 评论(0) 推荐(0) 编辑
摘要:http://blog.sina.com.cn/s/blog_4b3c1f950100kker.htmloperator是C++的关键字,它和运算符一起使用,表示一个运算符函数,理解时应将operator=整体上视为一个函数名。这是C++扩展运算符功能的方法,虽然样子古怪,但也可以理解:一方面要使运算符的使用方法与其原来一致,另一方面扩展其功能只能通过函数的方式(c++中,“功能”都是由函数实现的)。一、为什么使用操作符重载?对于系统的所有操作符,一般情况下,只支持基本数据类型和标准库中提供的class,对于用户自己定义的class,如果想支持基本操作,比如比较大小,判断是否相等,等等,则需要 阅读全文
posted @ 2012-02-12 18:18 简单--生活 阅读(139351) 评论(8) 推荐(11) 编辑
摘要://以下对上面的程序进行改进#include <iostream>using namespace std;class A{public: virtual void fn()=0; //如果这个声明后不定义的话,必须得声明为纯虚函数才行,不然不能通过编译}; //A类我中无fn成成员函数class B : public A{ public: void fn(){ cout<<" I am Class B"; };};class C : public A{ public: void fn(){ cout<<" I am Class 阅读全文
posted @ 2012-02-12 16:22 简单--生活 阅读(339) 评论(0) 推荐(0) 编辑
摘要:#include<QtGui/QApplication>#include<QPushButton>intmain(intargc,char*argv[]){QApplicationapp(argc,argv);QPushButton*button=newQPushButton("Quit");QObject::connect(button,SIGNAL(clicked()),&app,SLOT(quit()));button->show();app.exec();} 阅读全文
posted @ 2012-02-08 22:54 简单--生活 阅读(220) 评论(0) 推荐(0) 编辑
摘要:#include<QtGui/QApplication>#include<QLabel>Q_DECL_EXPORTintmain(intargc,char*argv[]){QApplicationapp(argc,argv);//QLabel*label=newQLabel("HelloQt!");//QLabel对像,QLabel是一个qt提供的小控件,显示一行文本QLabel*label=newQLabel("<h2><i>Hello</i><fontcolor=red>Qt!</f 阅读全文
posted @ 2012-02-08 22:45 简单--生活 阅读(256) 评论(0) 推荐(0) 编辑

简单--生活(CSDN)
点击右上角即可分享
微信分享提示