精華區beta Oversea_Job 關於我們 聯絡資訊
1) You have two classes that define a virtual function with the same name… class A { //... virtual float render(); }; class B { //... virtual float render(); }; Then you use multiple inheritance of A & B for a third class… class C : public A, public B { //... }; A: What would happen if your code contained a call to render() on an instance of a class C object? B: What is the best way to resolve any ambiguity? ========================================================================= 2) What is the minimum number of states needed for a Coke Machine that requires 35 cents and accepts nickels, dimes, and quarters? Briefly explain the necessary states. Assumptions: There is only one soda selection Whenever a user puts in more than is required, the machine will instantly return the excess change. ========================================================================= 3) Find the bugs in this class: class MyClass { public: MyClass(){} void SetData( char* data ) { delete m_data; m_data = new char[ strlen(data) ]; strcpy( m_data, data ); } MyClass& MyClass::operator=( MyClass rhs ) { SetData( rhs.m_data ); return *this; } private: char* m_data; }; ========================================================================= 4) Fix/Optimize this: string FindAddr( list<Employee> emps, string name ) { for( list<Empolyee>::iterator i = emps.begin(); i != emps.end(); i++ ) { if( *i == name ) { return i->addr; } } return ""; } ========================================================================= 5) A triangle T with vertices V0, V1, and V2 is illuminated by a directional light source L with direction D. Calculate the diffuse intensity if triangle T is to be flat shaded. ========================================================================= 6) Given a plane defined by P0 and a unit normal N, find the perpendicular distance from P1 to the plane. -- ※ 發信站: 批踢踢參(ptt3.cc) ◆ From: 128.2.13.170