假设有2个缓存L1和L2
在查看和旁听政策的情况下,有效访问时间是多少.
为什么这个代码在传递的对象不是Line类型时调用复制构造函数,并且没有等于operator/explicit调用.A行和A行()之间有区别吗?
我从许多在线教程中读到它应该是Line类型.我是C++的新手.请帮忙
#include <iostream>
using namespace std;
class Line
{
public:
int getLength( void );
Line( int len ); // simple constructor
Line( const Line &obj); // copy constructor
~Line(); // destructor
private:
int *ptr;
};
// Member functions definitions including constructor
Line::Line(int len)
{
cout << "Normal constructor allocating ptr" << endl;
// allocate memory for the pointer;
ptr = new int;
*ptr = len;
}
Line::Line(const Line &obj)
{
cout << "Copy constructor allocating ptr." << endl;
ptr …Run Code Online (Sandbox Code Playgroud)