Skip to content

Commit

Permalink
add ex 7.1 and 7.2 serie 80
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-maulaz authored Apr 1, 2022
1 parent 0dc2f10 commit d42ff06
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions ex80-allocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void main(){
}
```

# Ex 7
# Ex 7.1

Quel est l'affichage du programme suivant :

Expand All @@ -161,4 +161,29 @@ void ex2(){
Parent* p = new Enfant();
delete p;
}
```
```

# Ex 7.2

Quel est l'affichage du programme suivant :

> Sans le `virtual` dans la classe `Parent`

```CPP
struct Parent
{
Parent() { cout << "Constr parent" << endl; }
~Parent() { cout << "Destr parent" << endl; }
};

struct Enfant: public Parent
{
Enfant() { cout << "Constr enfant" << endl; }
~Enfant() { cout << "Destr enfant" << endl; }
};

void ex2(){
Parent* p = new Enfant();
delete p;
}
```

0 comments on commit d42ff06

Please sign in to comment.