I use a lot of dependency injection in my code. I also like to use interface-based programming. Between the two, I often end up with constructs that look like this (stripped down to its essence):
// MyClass.h
class MyClass
{
public:
struct Parameters
{
int v1;
int v2;
// etc. These are really pointers to dependencies,
// but int is sufficient to trigger the problem
};
static MyClass* Create(const Parameters& p);
virtual ~MyClass();
protected:
MyClass();
};
// MyClass.cpp
#include "stdafx.h"
#include "MyClass.h"
class MyClassImpl : public MyClass
{
public:
MyClassImpl(const Parameters& parameters)
{
// ...
}
// ...
};
MyClass* MyClass::Create(const Parameters& p)
{
return new MyClassImpl(p);
}
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
Any time I follow this pattern in my project, I am completely unable to get intellisense for Parameters anywhere inside the derived MyClassImpl. However, I do get intellisense inside the base MyClass. What's more, if I copy/paste the exact same code into a new project, it will work in both places. So something else in my project (maybe in stdafx?) must be a key ingredient, but I don't have any idea what. I have no (consistent) trouble with intellisense under any other circumstances.
Any ideas?
Followup: If I qualify Parameters with MyClass::, the problem does not occur. And crucially, the same is true if I rename the struct to anything other than Parameters. I'm guessing something in the mass of files included in the main project's stdafx must use that same identifier for something else.