Din moment ce vom face teste cu mai multe tipuri de date se intelege necesitatea crearii sortarii pe respectivele tipuri de date. Avem 2 variante:
1. Supraincarcarea functiilor - se pare ca se merge pe ideea asta.
2. Creare de functie generica cu prototipul:
void ???sort(void *array, int dimension, short int type);
unde tipul va avea constante predefinite{CHAR, INT , DOUBLE, *CHAR ....}
La o prima analiza se pare ca supraincarcarea pare mai lejer de realizat si pe care se merge.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anyway we could use base classes / derived classes but first I think it is important to focus on the effective implementation which will be ok if we sort for example (for the moment) integers.
Maybe others have different opinions and I'm curious to 'hear' them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Welcome to Open Discussion
Din moment ce vom face teste cu mai multe tipuri de date se intelege necesitatea crearii sortarii pe respectivele tipuri de date. Avem 2 variante:
1. Supraincarcarea functiilor - se pare ca se merge pe ideea asta.
2. Creare de functie generica cu prototipul:
void ???sort(void *array, int dimension, short int type);
unde tipul va avea constante predefinite{CHAR, INT , DOUBLE, *CHAR ....}
La o prima analiza se pare ca supraincarcarea pare mai lejer de realizat si pe care se merge.
Anyway we could use the first approach ( using templates ) (1 says something like that )
Or we could use the qsort model function:
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));
from stdlib ( I think this will come handy ).
Anyway we could use base classes / derived classes but first I think it is important to focus on the effective implementation which will be ok if we sort for example (for the moment) integers.
Maybe others have different opinions and I'm curious to 'hear' them.