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

推荐订阅源

N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
H
Hacker News: Front Page
Apple Machine Learning Research
Apple Machine Learning Research
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Security Latest
Security Latest
Cloudbric
Cloudbric
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LangChain Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
小众软件
小众软件
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
P
Privacy & Cybersecurity Law Blog
S
Security @ Cisco Blogs
博客园 - 【当耐特】
I
InfoQ
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
O
OpenAI News
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
量子位
宝玉的分享
宝玉的分享

博客园 - JohnHoo

IE8 报错,问题事件名称:APPCRASH,故障模块名称:StackHash_c4c3 Compiere相关的资料收录 Compiere是什么? 整理的 NBear 中文文档 西安.net俱乐部终于成立了! SQL Server 不存在或访问被拒绝 不能更新。数据库或对象为只读 javascript 调试 恢复IE中出错的FlashGet右键菜单 绝对路径和相对路径 windows server 2003的一些设置 ERP&CRM开源项目(转) TrackBack Test ASCII编码表 收集的一些blog(自己感兴趣的blog,会不断的更新) 无法在web服务器上启动调试,问题解决 无法在WEB服务器上启动调试,一个头痛的问题 十年MFC经历认识的Microsoft技术 dotText WebLog源码分析--开始篇
收集的两个编译的测试题
JohnHoo · 2005-11-18 · via 博客园 - JohnHoo

收集的两个编译的测试题

2005-11-18 17:53  JohnHoo  阅读(542)  评论()    收藏  举报

下面这两个小测试题,从网上收集的,有兴趣的可以试试,

先不要编译测试结果,根据感觉作答:

一:有这样一个类:
                 class T
                 {
                       protected string aaa;

                       public T(string val)
                            {   aaa = val;    }

                       public string GetString(T t)
                            {  return t.aaa;    }
                 }

和以下两种用法:
1):
   T t1 = new T("test");
   Console.WriteLine(t1.GetString(t1));
2):
   T t1 = new T("test1");
   T t2 = new T("test2");
   Console.WriteLine(t1.GetString(t2));

请选择答案并说明理由:
a) 编译不通过
b)第一种用法不能通过
c)第二种用法不能通过
d)都能通过

二:写出控制台输出的结果

using System; 
class Base 
{
   
private int m=2
   
public int GetM(Child c)
   {
      
return c.m;
   }
public int GetM(Base b)
   {
      
return b.m;
   }
   
   
public Base()
   {}
public Base(int m)
   { 
     
this.m = m; 
   }

class Child : Base 
{
   
private int m=1;
   
public new int GetM(Child c)
   {
     
return c.m;
   }
public Child(int m):base(m)
   {  
this.m = 4;  }
class test 

   
public static void Main() 
   { 
      Base b 
= new Base(); 
      Child c 
= new Child(3); 
      Console.WriteLine(b.GetM(c)); 
      Console.WriteLine(c.GetM(c));
      Console.WriteLine(b.GetM((Base)c));
   } 
}

很有意思的题目,不过第二题,我觉得不太好做,大家可以先猜猜结果,再去编译测试