C++类默认的成员函数与Java Object类中的成员函数
2016-10-16 16:56
281 查看
这两个问题虽然不太难,纯属记忆问题,但是在面试的时候还是很容易被问到的,再强调一次,面试还是很容易问到的……面试题目……
C++空类默认成员函数
Java Object类默认成员函数
C++空类默认成员函数
class EmptyCppClass { public: EmptyCppClass(); // 缺省构造函数 EmptyCppClass( const EmptyCppClass& ); // 拷贝构造函数 ~EmptyCppClass(); // 析构函数 EmptyCppClass& operator=( const EmptyCppClass& ); // 赋值运算符 EmptyCppClass* operator&(); // 取址运算符 const EmptyCppClass* operator&() const; // 取址运算符 const };
Java Object类默认成员函数
public class Object{ private static native void registerNatives(); static { registerNatives(); } public native int hashCode(); public boolean equals(Object obj) { return (this == obj); } protected native Object clone() throws CloneNotSupportedException; public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); } public final native void notify(); public final native void notifyAll(); public final native void wait(long timeout) throws InterruptedException; public final void wait(long timeout, int nanos) throws InterruptedException { if (timeout < 0) { throw new IllegalArgumentException("timeout value is negative"); } if (nanos < 0 || nanos > 999999) { throw new IllegalArgumentException( "nanosecond timeout value out of range"); } if (nanos > 0) { timeout++; } wait(timeout); } public final void wait() throws InterruptedException { wait(0); } protected void finalize() throws Throwable { } }
相关文章推荐
- C++类和对象、四个默认成员函数、运算符重载
- C++类和对象——四个默认成员函数+运算符重载
- C++类和对象--默认成员函数
- C++类的4个默认成员函数
- 详解C++类中的6个默认成员函数
- C++类和对象及其默认成员函数
- C++类的六个默认成员函数
- C++类和对象1--四个默认成员函数+运算符重载
- 隐式this指针及C++类中六个默认成员函数
- C++类和对象.四个默认成员函数(赋值运算符重载)
- 浅谈C++类中的默认成员函数
- C++类的默认成员函数
- c++类中六个默认成员函数
- C++类和对象及4个默认成员函数
- C++类成员函数中的函数指针参数
- C++中的空类,编译器默认可以产生哪些成员函数
- 类默认的成员函数
- C++类的静态成员函数在多线程的工作机制以及运行过程中强制结束线程实验
- C++空类的默认成员函数总结
- 在linux c++类中的成员函数里创建多线程要注意的地方