我有两个类,“缓存”和“LRU”:类缓存看起来像这样:
class cache
{
private:
int num_cold; //Number of cold misses
int num_cap; //Number of capacity misses
int num_conf; //Number of conflict misses
int miss; //Number of cache misses
int hits; //Number of cache hits
public:
// methods
}
我也在 LRU 类中有一个方法
bool LRU::access (Block block)
{
for (i = lru.begin(); i != lru.end(); i++) //If
{
if (i->get_tag() == block.get_tag() && i->get_index() == block.getIndex())
{
lru.push_back(block);
lru.erase(i);
return true;
//Here i want to add 1 to the value of variable "hits" of class "cache"
}
}
}
我想在“LRU::access”方法中增加“缓存”类中变量的值。有人可以告诉我我该怎么做。谢谢。