惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - 默默無語中

GridView分页-编辑-删除 DataList修改删除 - 默默無語中 - 博客园 弄了一晚上研究连接字符串,给自己留个清楚的回忆~! - 默默無語中 - 博客园 [数据库连接字符串] SQL Server 2005 Compact Edition 连接字符串 委托对象(收集) 委托的笔记(整理) [导入]asp.net高级教程(三)-实战篇 [导入]asp.net高级教程(三)-对象 [导入]asp.net高级教程(五)-实战篇(中) [导入].NET之ASPWebApplication快速入门(3) [导入].NET之ASPWebApplication快速入门(2) [导入].NET之ASPWebApplication快速入门(1) [导入].NET之ASPWebApplication快速入门(4) [导入].NET之ASPWebApplication快速入门(5) [导入]asp.NET特写 [导入]亲密接触ASP.Net(1) [导入]亲密接触ASP.Net(3) [导入]亲密接触ASP.Net(4) [导入]亲密接触ASP.Net(2) [导入]亲密接触ASP.Net(6) [导入]亲密接触ASP.Net(5)
类与结构的区别
默默無語中 · 2012-03-28 · via 博客园 - 默默無語中

1,类中的变量默认是private,结构则是public;

2,class是引用类型,struct是值类型。

3,结构不能从另一个类或者结构继承。也不能被继承。但是可以继承接口。

4,不能在机构体中定义默认构造函数,但是可以添加构造函数。不能定义结构的无参构造函数没有析构函数。

 struct Date
{
private int year;
private Month month;
private int day;

public Date() ----提示错误(无参构造函数
{ }
}

5,结构的对象不能赋值为null。

6,不能使用abstruct和saaled,不能使用protected关键字,因为不能继承。 可以不适用new初始化。

7,在结构体的非默认构造方法种必须对结构体中所有的字段进行初始化,否则将报错。在结构中不能对字段初始化。

  struct Date
{
private int year=0; ----报错(在类中声明字段的同时可以初始字段值,但在结构体中不可以)
private Month month;
private int day;

public Date(int ccyy, Month mm, int dd)
{
year = ccyy - 100;
this.month = mm;
// this.day = dd - 1; -----报错(必须对结构体中所有的字段进行初始化)
}
}