2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

Autodesk 的 c 題(2007.05) - 面試總結(jié) - 堅(jiān)持到底

 ShaneWu 2009-12-08
Autodesk 的 c++題(2007.05)

1. What and why is explicit constructor and explicit copy constructor?

2. What the difference between Struct and Class?

3. What is vitrual function and why we need vtable?

1.

Explicit constructor and copy constructor is used to preventing implicit type cast.

An explicit constructor can not take part in implicit conversions. It can only be  used to explicit construct an object

Consider the Class below:

class A

{

public:

A();

A(int i);

A(A& a);

int i;

virtual ~A();

};

The following program will success to compile :

A a = 10;

or

A a;

a = 10;

because A has a constructor that accept a Int as a arguments

Those codes above are equal to

A tmp(10);    //constructor

a(tmp);      //copy constructor

or

A tmp(10) ;  //constructor

a = tmp;     // operator =

Note: explicit on a constructor with mutiple arguments has no effect,  unless all  but one of the arguments has a default value !

2: differences between struct and class?

3 difference between struct and class

1)members in struct are by default public while members in class are by default  private.

2)inhert  from  a struct is by default public , inhert from a class is by default private.

For example

struct A

{

};

struct B : (public)A

{

} ;

class A

{

};

class B: (private)A

{

};

3)class can be used as typename in template while struct can not

template(class T)      //right

template(struct T)     //wrong

3: What is virtual function and why we need vtable?

1) a virtual function is a function member of a class decleared with a virtual  keyword

2) it usually has a different functionality in the derived class

3) A function is resolved at run-time

The main difference between a non_virtual function and a virtual  function is, the  non_virtual function is resolved at compile time. This  mechanism is called  static_binding.  As the virtual function is  resolved at run time, This mechanism is  know as dynamic_binding

v_table is kind of lookup table.It contains pointers to the virtual  functions provided  by a class, and each object of the class contains a  pointer to its v_table(or  vtables, in some multiple-inheritance  situations)

A v_table is created at compile time,  so whether  a object is referenced by any  pointers or reference, when a virtual  fall happens, the v_table can help the object  find the exact function  address.

 原文地址 http://www./career/?p=17465

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多