以下程序片断是否正确? #include "iostream.h" class Person { private: int m_nAge;[br][/br] public:[br][/br] int GetAge();[br][/br] };[br][/br] int Person:: GetAge() { return m_nAge; } void main()[br][/br] { Person person1; person1.m_nAge=10; cout<
举一反三
- 下列表达式中正确的是()。 A: struct person{<br/>int age; <br/>char<br/>name[8];<br/>char sex;<br/>}personl,person2; B: struct person{<br/>int <br/>age;<br/>char<br/>name[8]; <br/>char sex;<br/>} person<br/>personl,person2; C: struct person{<br/>int <br/>age;<br/>char<br/>name[8];<br/>char sex;<br/>};personl,person2; D: struct person{<br/>int <br/>age;<br/>chat<br/>name[8]="WangLin";<br/>char<br/>sex="M";<br/>} person1
- class Person { String name; int age; [br][/br] public Person(String name, int age) { super(); this.name = name; this.age = age; } @Override public boolean equals(Object obj) { Person person=null; if(obj instanceof Person) person=(Person)obj; if(name.equals(person.name)&&age==person.age) return true; return false; } } class Test{ public static void main(String[] args) { Person person1 = new Person("张三", 12); Person person2 = new Person("张三", 12); System.out.println(person1.equals(person2));//运行结果是? } } 程序运行结果是什么? A: true B: false
- class Person {private int a;public int change(int m){ return m; }}public class Teacher extends Person {public int b;public static void main(String arg[]){Person p = new Person();Teacher t = new Teacher();int i;// point x}}在 // point x安排哪个语句合法?
- 对结构变量 person的出生年份进行赋值时,下列中正确的赋值语句是( )。[br][/br]struct date{int year;int month;int day};[br][/br]struct man[br][/br]{[br][/br]char name|20];[br][/br]char sex;[br][/br]struct date birthday;[br][/br]}person; A: year=1958; B: irthday.year=1958; C: person.birthday.year=1958; D: person.year=1958;
- 以下代码 function Person() {[br][/br] this.name = '张三';[br][/br] }[br][/br] Person.prototype.name = '李四';[br][/br] var p = new Person();[br][/br] console.log(p.name); 执行后的输出结果____。