Reputation: 7280
I have two classes, "cache" and "LRU": Class cache looks something like this:
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
}
Also i have a method in class 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"
}
}
}
I want to increment the values of variables in class "cache" in the method "LRU::access". Could someone please tell me how i can do that. Thanks.
Upvotes: 0
Views: 153
Reputation: 37940
Add this to cache
:
friend class LRU;
This will let any code in LRU
access all private members of cache
.
Upvotes: 4