今天试了一下VC++对于inline的优化是如何做的。主要是因为近段日子在手机上看Effective C++的缘故。
==test1.h==
class Test1
{
public:
Test1();
~Test1();
inline int GetXFromH() { return x; }
inline int GetXFromCPP();
private:
int x;
};
==test1.cpp==
#include “test1.h”
#include <stdio.h>
Test1::Test1()
{
x = 10;
}
Test1::~Test1()
{
x = -1; <