09 2019 档案
摘要:1 package com.Shen; 2 3 public class Test2 { 4 public static void main(String args[]){ 5 AreaRect rect1;//声明对象,用AreaRect 这个类来声明rect这个对象(变量),类是一种数据类型 6 rect1=new AreaRect(); 7 /*new:为rect1这个对象分配变量(一种运算
阅读全文
摘要:1 //自定义函数 2 #include<iostream> 3 using namespace std; 4 int Area(w,h);//错误:参数要先定义再使用,所以c前要有c的类型。正确表述:Area(int w,int h) 5 int main() { 6 int a,b; 7 cin >> a>> b; 8 cout << Area(a,b) << endl; 9 } 10 int
阅读全文
摘要:1 //强制转换 2 #include<iostream> 3 using namespace std; 4 int main() { 5 int a(4); 6 //将4赋值给a 7 double b =a; 8 cout << b <<endl<<sizeof(b)<<endl << sizeof(a)<<endl; 9 return 0; 10 } 1 //强制转换 2 #include<i
阅读全文
摘要:函数定义由函数头和函数体构成,函数头:返回类型,函数名,函数参数;函数体:花括号中内容。
阅读全文