| export default {} |
| |
| class Person { |
| public name: string; |
| protected age: number; |
| private sex: string; |
| |
| constructor(name: string, age: number, sex: string){ |
| this.name = name; |
| this.age = age; |
| this.sex = sex; |
| } |
| |
| say():void { |
| console.log(`我的名字是${this.name}, 性别为${this.sex}, 今年${this.age}岁了`); |
| |
| } |
| } |
| |
| let p = new Person("邱淑贞", 18, "女"); |
| p.say(); |
| |
| class Student extends Person { |
| score: string |
| constructor(name: string, age: number, sex: string, score: string){ |
| super(name, age, sex); |
| this.score = score; |
| } |
| show(): void { |
| console.log(this.name); |
| console.log(this.age); |
| console.log(this.score); |
| |
| |
| } |
| } |
| |
| |
| |
| |
| |
| class PrintConsole { |
| readonly str1: string = "HTML, CSS, JS, VUE, REACT, NODE"; |
| readonly str2: string; |
| readonly str3: string; |
| readonly str4: string; |
| |
| constructor(str2: string, str3: string, str4: string){ |
| this.str2 = str2; |
| this.str3 = str3; |
| this.str4 = str4; |
| } |
| } |
| |
| let pc = new PrintConsole("我的头发去哪了,颈椎康复指南", |
| "35岁失业了该怎么办, 外卖月入一万也挺好", |
| "活着") |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南