Question

Suppose I have two 2D arrays (in my case they are L1 and L2 caches and each position in these two arrays are structures). I've created these already. I want to create a third array of size 'n' where every position will contain both the previously created 2D arrays. How can I do this in C++? Basically my third array resembles a multi core architecture where each core has its individual L1 and L2 caches. Any ideas? Thanks!

Was it helpful?

Solution

Well, it is C++, so why not create a class?

class tCache {
     // put the L1 and L2 arrays in here
};

I mean, std::pair would probably work but you're gonna have ugly code if you just use that...

OTHER TIPS

you can create an array of structure containing 2 pointer to the the cache L1 and L2. Then use it to access the arrays.

struct L
{
L1 (*pl1) [][];
L2 (*pl2) [][];
};

struct L l;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top