# Constructor Injection in Dependency Injection
Constructor injection supplies required dependencies when an object is created. It is a useful default because a successfully constructed instance has everything it needs to operate.
Let's say we have a simple example of a `Computer` class that depends on another class, `CPU`. We can use construction injection to provide the `CPU` class to the `Computer` constructor like so:
```typescript
class CPU {
public brand: string;
constructor(brand: string) {
this.brand = brand;
}
}
class Computer {
public cpu: CPU;
constructor(cpu: CPU) {
this.cpu = cpu;
}
}
const amd_cpu: CPU = new CPU("AMD");
const computer: Computer = new Computer(amd_cpu);
```
With construction injection, our Computer class is no longer responsible for creating its own dependencies.
Instead, it's provided with everything it needs to work correctly.
Constructor Injection in Dependency Injection
Constructor injection supplies required dependencies when an object is created. It is a useful default because a successfully constructed instance has everything it needs to operate.
Let’s say we have a simple example of a Computer class that depends on another class, CPU. We can use construction injection to provide the CPU class to the Computer constructor like so:
With construction injection, our Computer class is no longer responsible for creating its own dependencies.
Instead, it’s provided with everything it needs to work correctly.