zoukankan      html  css  js  c++  java
  • 第二十章:封装与继承

    代码 :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace 封装
    {
        class Program
        {
            static void Main(string[] args)
            {
                Teacher st = new Teacher();
                //st.str
                int a= st.Sum(1, 2);
    
                Sudent s = new Sudent();
                int b= s.Sum(2, 3);
                Console.WriteLine(a);
                Console.ReadKey();
            }
        }
        public class Teacher
        {
            /// <summary>
            /// 封装计算和的方法
            /// </summary>
            /// <param name="a"></param>
            /// <param name="b"></param>
            /// <returns></returns>
            public int Sum(int a, int b)
            {
    
                int result = a + b;
                return result;
            }
            //{ }  int a=1;
            //方法有两种形式,一种是有返回值,一种是没返回值 void
            // string 字符串  int 数字  double  小数 bool 真假值  list<T>  
    
            //void  表示不返回值
            public string str()
            {
                
                Console.WriteLine("234wer");
                return "";
            }
        }
        /// <summary>
        /// 继承   :对象
        /// </summary>
        public class Sudent : Teacher
        {
    
        }
    }
  • 相关阅读:
    PPT1 例1
    皇宫看守 树形DP
    没有上司的晚会 树形DP
    将功补过 树形DP
    战略游戏 树形DP
    选课 树形DP
    二叉苹果树 树形DP
    GDOI2016总结
    加分二叉树 树形DP
    [注意]未做的题(最短路)
  • 原文地址:https://www.cnblogs.com/wangqiangya/p/13062590.html
Copyright © 2011-2022 走看看