
c#/c++
文章平均质量分 64
masterall
这个作者很懒,什么都没留下…
展开
-
C++特性探寻-多态和虚函数
在C++中,多态是通过虚函数实现的。基类如果把一个函数声明为虚的(virtual),就表明继承类可以覆盖(override)这个函数(从而表现不同的行为,呈现出多态性)。对于每一个有虚函数的具体类(或者继承类),可认为有一个与之关联的虚函数表(v-table)。v-table表中的每一项(slot)中存储的是适当的函数指针。C++编译器在编译时刻创建了所有必需的虚函数表。并且,每个虚函数表中的项都原创 2005-09-01 10:57:00 · 996 阅读 · 0 评论 -
C++特性探寻-可变参数和参数进栈顺序
C支持可变参数的函数,这里的意思是C支持函数带有可变数量的参数,最常见的例子就是我们十分熟悉的printf()系列函数。我们还知道在函数调用时参数是自右向左压栈的。如果可变参数函数的一般形式是: f(p1, p2, p3, …)那么参数进栈(以及出栈)的顺序是: … push p3 push p2 push p1 call f pop p1 pop原创 2005-09-01 10:58:00 · 1296 阅读 · 0 评论 -
C++特性探寻-继承、成员函数、this指针
继承和对象净增长C++中类的继承,是具有净增长效果的。如果基类是Base,继承类是Derived,那么创建一个Derived类的实例b,在地址空间上,b的前面部分,刚好可以视为另一个Base的实例(a),后面才是继承所带来的扩展数据部分。所以继承具有净增长或者说净扩展效果。C++的继承绝不会破坏基类的数据结构,这可以肯定是一个基本原则。因为如此,所以C++对象可以安全下塑造型(downcast):原创 2005-09-01 10:59:00 · 1917 阅读 · 0 评论 -
C++特性探寻-参数传递和返回值
对于原始类型(或称基本类型),如int, char, float, 指针 等,参数传递和返回值不会碰到什么难以理解的问题。能引起关注的焦点是,当我们把对象作为参数传递,或者返回一个对象时,这里面发生了什么?我个人觉得,“返回一个对象”的说法或概念尤其难以理解。例如函数f()返回一个对象(类A的实例): A a; a = f(); // 或者: f().f1(); //原创 2005-09-01 11:01:00 · 1032 阅读 · 0 评论 -
C++特性探寻-构造函数和析构函数
构造函数提供了一种机制,通过它有机会完成必要的初始化工作,从而使对象成为有意义的存在物,而不仅仅只是一块原始的空间。但是,我们逐渐了解到,构造函数具有的地位,不仅对于用户(程序员),对于编译器履行职责也极为重要。通过这个机制,它让C++的一些基本的特性,如继承、多态得到了正确的贯彻和表现。首先不难理解的一点是在构造函数中,要确保基类对象的正确构造,如果是从基类继承的话。因为继承类对象至少可以被“低原创 2005-09-01 11:02:00 · 1218 阅读 · 1 评论 -
C#重点知识详解(一)
在微软的.NET推出后,关于C#的有关文章也相继出现,作为微软的重要的与JAVA抗衡的语言,C#具有很多优点。本文将选一些C#语言中的重要知识详细介绍, 第一章:参数 1。1 IN 参数 c#种的四种参数形式: 一般参数 in参数 out参数 参数数列 本章将介绍后三种的使用。 在C语言你可以通传递地址(即实参)或是DELPHI语言中通过VAR指示符传递地址参数来进行数据排序等操作,在C#语言中,原创 2005-05-04 00:45:00 · 1271 阅读 · 1 评论 -
c#重点知识详解(三)
第三章: 类属性 使用过RAD开发工具的一定inspector很熟悉,程序员通过它可以操作对象的属性,DELPHI中引入了PUBLISH关键字来公布对象属性受到程序员的普遍欢迎.通过存取标志来访问private成员,在c#中有两种途径揭示类的命名属性——通过域成员或者通过属性。前者是作为具有公共访问性的成员变量而被实现的;后者并不直接回应存储位置,只是通过存取标志(accessors)被访问。当你原创 2005-05-04 00:47:00 · 963 阅读 · 0 评论 -
c#重点知识详解(四)
第四章:C# 中的加框与去框 C# 运行时中有两种类型:引用类型(reference)(在 C# 中用类声明)和值类型(value)(在 C# 中用结构声明)。引用和值类型在几个重要方面有所不同。值类型“感觉上”象一个数据。它包括预定义数值类型(如int、bool)以及用户定义的类型(circle、Point等)。如上文所述,值类型的变量是实际的值,所以在您使用变量时,通常处理的是实际的值。 1>原创 2005-05-04 00:48:00 · 1030 阅读 · 0 评论 -
c#重点知识解答(五)
第五章:代理 代理实现的是象c++等语言的指针功能,不同于函数指针,代理是一种面向对象、安全类型的。代理事派生于公共基类(system)的一种参考类型,方法被压入一个代理中,对于实例方法被称为实例的组成实体或关于实例的方法,而静态方法,被称为类的组成实体或类方法。代理的强大功能是它可以自动的匹配方法,而不管其类型。 写一个代理包括三个步骤: 写代理、实例化、调用。 代理的声明使用以下语法: del原创 2005-05-04 00:50:00 · 1009 阅读 · 0 评论 -
c#重点知识详解(六)
如同java一样,在c#中写一个多线程应用是非常简单的,本章将介绍如何在c#种开发多线程程序。在.net中线程是由System.Threading 名字空间所定义的。所以你必须包含这个名字空间。 using System.Threading; 开始一个线程 System.Threading 名字空间的线程类描述了一个线程对象,通过使用类对象,你可以创建、删除、停止及恢复一个线程。创建一个新线程通过原创 2005-05-04 00:51:00 · 1251 阅读 · 0 评论 -
C#重点知识详解(二)
第二章 内存管理 c#内存管理提供了与java一样的自动内存管理功能,让程序员从繁重的内存管理中摆脱出来,内存管理提高了代码的质量和提高了开发效率。 c#限制了着指针的使用,免除了程序员对内存泄漏的烦恼,但是不是意味着向java程序员一样c#程序员在也不能使用指针代来的好处。微软在设计C#语言时考虑到这个问题,在一方面抛弃指针的同时,另一方面采用折衷的办法,通过一个标志来时程序引入指针。 首先我们原创 2005-05-04 00:46:00 · 1023 阅读 · 0 评论 -
利用c#制作简单的留言板(2)
myconn.csnamespace notpage{using System;using System.Data.SQL ; /// /// Summary description for myconn./// public class myconn:System.Data.SQL.SQLConnection{private void InitializeComponent (){}public原创 2005-05-29 23:34:00 · 1419 阅读 · 0 评论 -
利用c#制作简单的留言板(3)
显示列表list.aspx 发表留言主题留言人留言时间 namespace notpage{using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;us原创 2005-05-29 23:40:00 · 1906 阅读 · 0 评论 -
利用c#制作简单的留言板(4)
查看留言内容showtopic.aspx察看留言留言主题: 留言时间:留言人:id=n_tdAuthor runat="server" forecolor="Black">留言内容:runat="Server" forecolor="Black"> 对应的csnamespace notpage{using System;using System.Collections;using System.C原创 2005-05-29 23:41:00 · 1457 阅读 · 0 评论 -
利用c#制作简单的留言板(1)
留言板分三个模块:列出留言列表、显示详细内容、发表留言notepage.csnamespace notpage{using System;using System.Data.SQL ;using System.Data ;using System.Collections ;/// /// Summary description for notepage./// public class notep原创 2005-05-29 23:28:00 · 2811 阅读 · 1 评论 -
C++中的健壮指针和资源管理(1)
资源及它们的所有权 我最喜欢的对资源的定义是:"任何在你的程序中获得并在此后释放的东西。"内存是一个相当明显的资源的例子。它需要用new来获得,用delete来释放。同时也有许多其它类型的资源文件句柄、重要的片断、Windows中的GDI资源,等等。将资源的概念推广到程序中创建、释放的所有对象也是十分方便的,无论对象是在堆中分配的还是在栈中或者是在全局作用于内生命的。原创 2005-06-12 00:35:00 · 955 阅读 · 0 评论 -
Table of Contents
1. Scope.................................................................. 12. Conformance ........................................................ 33. References .....................................原创 2005-11-27 20:53:00 · 950 阅读 · 0 评论 -
4. Definitions
For the purposes of this International Standard, the following definitions apply. Other terms are definedwhere they appear in italic type or on the left side of a syntax rule. Terms explicitly defined原创 2005-11-27 20:56:00 · 818 阅读 · 0 评论 -
8.2.1 Predefined types
8.2.1 Predefined typesC# provides a set of predefined types, most of which will be familiar to C and C++ developers.The predefined reference types are object and string. The type object is the ultimat原创 2005-11-27 21:08:00 · 844 阅读 · 0 评论 -
8.2.3 Array types
8.2.3 Array typesArrays may be single-dimensional or multi-dimensional. Both .rectangular. and .jagged. arrays aresupported.Single-dimensional arrays are the most common type. The exampleusing System;原创 2005-11-27 21:09:00 · 779 阅读 · 0 评论 -
C++中的健壮指针和资源管理(2)
Resource Transfer 到目前为止,我们所讨论的一直是生命周期在一个单独的作用域内的资源。现在我们要解决一个困难的问题--如何在不同的作用域间安全的传递资源。这一问题在当你处理容器的时候会变得十分明显。你可以动态的创建一串对象,将它们存放至一个容器中,然后将它们取出,并且在最终安排它们。为了能够让这安全的工作--没有泄露--对象需要改变其所有者。 这个原创 2005-06-12 00:36:00 · 1297 阅读 · 0 评论 -
C++中的健壮指针和资源管理(3)
std::auto_ptr后来我意识到在STL中的auto_ptr模板,就是我的Strong Pointer。在那时候还有许多的实现差异(auto_ptr的Release方法并不将内部的指针清零--你的编译器的库很可能用的就是这种陈旧的实现),但是最后在标准被广泛接受之前都被解决了。Transfer Semantics(转换语义学)目前为止,我们一直在讨论在C++程序中资源管原创 2005-06-12 00:36:00 · 1026 阅读 · 0 评论 -
8.7.1 Constants & 8.7.2 Fields
8.7.1 ConstantsA constant is a class member that represents a constant value: a value that can be computed at compile-time.Constants are permitted to depend on other constants within the same program原创 2005-11-30 19:09:00 · 643 阅读 · 0 评论 -
4. Definitions (cont')
Implementation . particular set of software (running in a particular translation environment underparticular control options) that performs translation of programs for, and supports execution of metho原创 2005-11-27 20:56:00 · 662 阅读 · 0 评论 -
6. Acronyms and abbreviations
This clause is informative.The following acronyms and abbreviations are used throughout this International Standard:BCL . Base Class Library, which provides types to represent the built-in data types原创 2005-11-27 21:06:00 · 743 阅读 · 0 评论 -
8.2.2 Conversions
8.2.2 ConversionsThe predefined types also have predefined conversions. For instance, conversions exist between thepredefined types int and long. C# differentiates between two kinds of conversions: im原创 2005-11-27 21:08:00 · 779 阅读 · 0 评论 -
8.4 Automatic memory management
8.4 Automatic memory managementManual memory management requires developers to manage the allocation and de-allocation of blocks ofmemory. Manual memory management can be both time-consuming and diffi原创 2005-11-28 22:15:00 · 778 阅读 · 0 评论 -
8.4 Automatic memory management(cont')
public void Push(object o) {first = new Node(o, first);}class Node{public Node Next;public object Value;public Node(object value): this(value, null) {}public Node(object value, Node next) {Next = next原创 2005-11-28 22:16:00 · 823 阅读 · 0 评论 -
8.7.6 Operators
An operator is a member that defines the meaning of an expression operator that can be applied to instancesof the class. There are three kinds of operators that can be defined: unary operators, binary原创 2005-11-30 19:11:00 · 627 阅读 · 0 评论 -
8.7.8 Instance constructors
An instance constructor is a member that implements the actions required to initialize an instance of a class.The exampleusing System;class Point{public double x, y;public Point() {this.x = 0;this.y =原创 2005-11-30 19:12:00 · 790 阅读 · 0 评论 -
8.10 Delegates
8.10 DelegatesDelegates enable scenarios that some other languages have addressed with function pointers. However,unlike function pointers, delegates are object-oriented and type-safe.A delegate decla原创 2005-11-30 19:16:00 · 828 阅读 · 0 评论 -
8.11 Enums
8.11 EnumsAn enum type declaration defines a type name for a related group of symbolic constants. Enums are used for.multiple choice. scenarios, in which a runtime decision is made from a fixed number原创 2005-12-02 11:34:00 · 879 阅读 · 0 评论 -
8.13 Versioning
8.13 VersioningVersioning is the process of evolving a component over time in a compatible manner. A new version of acomponent is source compatible with a previous version if code that depends on the原创 2005-12-02 22:29:00 · 920 阅读 · 0 评论 -
9. Lexical structure
9. Lexical structure原创 2005-12-02 22:30:00 · 810 阅读 · 0 评论 -
9.4.1 Unicode escape sequences
9.4.1 Unicode escape sequencesA Unicode escape sequence represents a Unicode character. Unicode escape sequences are processed inidentifiers (§9.4.2), regular string literals (§9.4.4.5), and character原创 2005-12-02 22:34:00 · 2059 阅读 · 0 评论 -
9.4.4.5 String literals
9.4.4.5 String literalsC# supports two forms of string literals: regular string literals and verbatim string literals. A regular stringliteral consists of zero or more characters enclosed in double qu原创 2005-12-02 22:40:00 · 986 阅读 · 0 评论 -
9.4.5 Operators and punctuators
9.4.5 Operators and punctuatorsThere are several kinds of operators and punctuators. Operators are used in expressions to describe operationsinvolving one or more operands. [Example: For example, the原创 2005-12-02 22:41:00 · 759 阅读 · 0 评论 -
9.5.3 Declaration directives
9.5.3 Declaration directivesThe declaration directives are used to define or undefine conditional compilation symbols.pp-declaration::whitespaceopt # whitespaceopt define whitespace conditional-symbol原创 2005-12-02 22:42:00 · 816 阅读 · 0 评论 -
9.5.4 Conditional compilation directives
9.5.4 Conditional compilation directivesThe conditional compilation directives are used to conditionally include or exclude portions of a source file.pp-conditional::pp-if-section pp-elif-sectionsopt原创 2005-12-02 22:43:00 · 834 阅读 · 0 评论 -
9.5.5 Diagnostic directives
9.5.5 Diagnostic directivesThe diagnostic directives are used to explicitly generate error and warning messages that are reported in the sameway as other compile-time errors and warnings.pp-diagnostic原创 2005-12-02 22:43:00 · 837 阅读 · 0 评论