Question: I'm consolidating 2 programs into one, and in 2 different files (I have many files), I have a typedef with the same name, different types though. 

These types will be used in completely different parts of the program and will never talk to each other, or be used interachangely.

I can of cause just do a search replace in one of the files, but I was wondering if there is another solution to this.

Something like binding a typedef to a specific file.
Or making a typedef local to a class and it's subclasses.

Thanks

Answer: 
You can encapsulate those `typedef` inside a `namespace`:

```
namespace N1 {
  typedef int T;
}
namespace N2 {
  typedef int T;
}

```

And in whatever file you want to use first `typedef` simply declare:

```
using namespace N1;

```

same thing for the other one also.
> 
> [...]Or making a typedef local to a class
>  and it's subclasses.
> 
> 
> 

Well, that's simple: 

```
struct A
{
 typedef int X;
}; 

struct B : A 
{ 
 X a; 
}; 

struct C
{
 typedef double X;
}; 

```

Typedefs are scoped in C++.