0
How do I vector objects using c++? And how do I sort this array of objects, for example, using some sort algorithm (quicksort, mergesort, shellsort or radixsort)?
#include <iostream>
using namespace std;
class Game {
public:
float preco;
char nome[25];
int idade;
char categoria[30];
};
int main (){
Game *jogo = new Game();
int i;
//for (i=0; i < 2; i++){
cout <<"Digite o preço do jogo: \n";
cin >> jogo->preco;
cout <<"Digite a nome do jogo: \n";
cin >> jogo->nome;
cout <<"Digite a idade indicativa para joga-lo : \n";
cin >> jogo->idade;
cout <<"Qual a categoria do jogo: \n";
cin >> jogo->categoria;
//}
cout << jogo->preco <<"\n";
cout << jogo->nome << "\n";
cout << jogo->idade << "\n";
cout << jogo->categoria << "\n";
return 0;
}
Related: https://answall.com/a/210524/64969; has a whole interesting theoretical basis, despite being about chained list
– Jefferson Quesado
I’m not a fan of this type of code because it is half C and Mio C++, I don’t even know what I offer since I don’t know if you want to program in C or C++. Looks like it’s C++, so that code should be rewritten.
– Maniero
@Maniero would be interanssante if you had indicated to him what he should change in the code and not simply mandalo rewrite it...
– user83187