问个内联函数问题
c++吧
全部回复
仅看楼主
level 11
gameloftyou 楼主
代码:
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class Example
{
    string name;
    
    public:
    
    Example(string sname)
    {
        name = sname;
    }
    string getName() const
    {
        return name;
    }
};
int main()
{
    Example exa("Jim");
    cout<<exa.getName()<<endl;
    //这一句exa.getName()编译时能不能内联展开,用exa.name肯定不行,还是说类里面的内联函数只在类内部调用时才展开
    system("pause");
    return 0;
}
2012年07月27日 12点07分 1
level 7
试问这里的展开是何意?
2012年07月27日 13点07分 2
level 7
试问这里的展开是何意?
2012年07月27日 13点07分 3
在编译时,内联函数不是会在调用的地方展开么。我这里是问能不能展开,怎样展开。
2012年07月27日 13点07分
level 9
应该是你说的第二种情况!!
2012年07月27日 13点07分 4
1