text stringlengths 0 2.35k |
|---|
[1349.40 --> 1350.00] this code |
[1350.00 --> 1351.56] in C++, |
[1351.82 --> 1352.60] we have to have, |
[1352.70 --> 1353.52] we have to use |
[1353.52 --> 1354.68] this kind of code |
[1354.68 --> 1355.38] with templates |
[1355.38 --> 1356.82] to plug in something |
[1356.82 --> 1357.78] into something else, |
[1357.78 --> 1359.08] to even be able |
[1359.08 --> 1359.76] to do that, |
[1359.82 --> 1360.64] to just plug in |
[1360.64 --> 1361.38] some functionality |
[1361.38 --> 1362.32] into something else |
[1362.32 --> 1363.34] that it's not aware of. |
[1363.44 --> 1363.62] Again, |
[1363.72 --> 1364.64] because interfaces, |
[1365.24 --> 1365.38] well, |
[1365.50 --> 1367.00] C++ doesn't have interfaces. |
[1367.22 --> 1368.06] It has classes |
[1368.06 --> 1369.52] where you can define |
[1369.52 --> 1370.84] functions as pure virtual, |
[1371.44 --> 1372.20] so it doesn't have |
[1372.20 --> 1373.48] to have all the implementation. |
[1374.36 --> 1374.84] But, |
[1375.08 --> 1376.80] whatever object you have, |
[1376.84 --> 1377.76] you cannot pass in |
[1377.76 --> 1378.30] as another |
[1378.30 --> 1379.62] unless it implements, |
[1380.08 --> 1381.40] it extends |
[1381.40 --> 1382.72] or is essentially |
[1382.72 --> 1384.04] a class. |
[1384.62 --> 1385.62] But in this case, |
[1385.62 --> 1387.18] you define your own |
[1387.18 --> 1388.84] event handler, |
[1389.08 --> 1389.52] obviously, |
[1389.66 --> 1390.54] nobody knows, |
[1390.98 --> 1391.54] you can't really |
[1391.54 --> 1392.42] pass in |
[1392.42 --> 1393.66] or use in this code |
[1393.66 --> 1394.40] any class |
[1394.40 --> 1394.74] that you didn't |
[1394.74 --> 1395.44] write yourself. |
[1395.96 --> 1396.38] So, |
[1396.46 --> 1397.16] you get stuck |
[1397.16 --> 1398.18] and this is why |
[1398.18 --> 1399.34] you use generics |
[1399.34 --> 1400.42] in many, |
[1400.52 --> 1401.08] many languages. |
[1401.42 --> 1402.24] It's for this case |
[1402.24 --> 1403.46] and that was why |
[1403.46 --> 1404.36] for many, |
[1404.50 --> 1405.04] many years |
[1405.04 --> 1405.96] people would say, |
[1406.08 --> 1406.12] well, |
[1406.16 --> 1406.66] why do you need |
[1406.66 --> 1407.26] interfaces? |
[1407.74 --> 1408.30] Why do you need |
[1408.30 --> 1409.06] generics when you |
[1409.06 --> 1409.78] have interfaces? |
[1410.26 --> 1411.14] But the truth is |
[1411.14 --> 1411.84] that you do need |
[1411.84 --> 1413.08] generics for the cases |
[1413.08 --> 1414.84] where the behavior |
[1414.84 --> 1416.26] of the class |
[1416.26 --> 1417.00] is derived |
[1417.00 --> 1419.04] by the type. |
[1419.70 --> 1419.88] So, |
[1420.10 --> 1420.70] for instance, |
[1421.20 --> 1422.68] next node |
[1422.68 --> 1424.12] in a linked list. |
[1424.76 --> 1424.92] So, |
[1425.42 --> 1426.22] the next is going |
[1426.22 --> 1426.76] to return |
[1426.76 --> 1427.58] the same type |
[1427.58 --> 1428.00] of node |
[1428.00 --> 1428.74] and if your node |
[1428.74 --> 1429.20] is holding |
[1429.20 --> 1429.72] an integer |
[1429.72 --> 1430.46] or a float |
[1430.46 --> 1431.04] or whatever |
[1431.04 --> 1432.08] type of value, |
[1432.32 --> 1432.92] it's going |
[1432.92 --> 1433.90] to be different. |
[1434.42 --> 1435.20] A repository |
[1435.20 --> 1436.00] that stores |
[1436.00 --> 1437.16] any kind of model. |
[1437.70 --> 1438.22] A map |
[1438.22 --> 1439.18] with a key |
[1439.18 --> 1440.26] value. |
[1440.38 --> 1440.98] By the way, |
[1441.48 --> 1442.42] go always |
[1442.42 --> 1443.28] hot generics. |
[1443.28 --> 1443.88] Actually, |
[1443.98 --> 1444.56] that would be |
[1444.56 --> 1445.90] my unpopular |
[1445.90 --> 1446.34] opinion. |
[1446.80 --> 1447.24] Go always |
[1447.24 --> 1447.94] hot generics |
[1447.94 --> 1448.94] because map |
[1448.94 --> 1449.82] is a generic |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.