4
Creating a class that will have two methods one assign another to print vectors with public
and then call this method no main
.
I was able to make it this far with the method baby Steps. Where I’m going wrong and what I have to do?
#include <iostream>
using namespace std;
class vetor
{
int v, tamanho,vetores;
public:
void atribuir(int *v, int tamanho){
for (int i=0; i<tamanho; i++) {
cout << "Digite um numero: ";
cin >> v[i];
}
}
void mostrar(void)
{
for (int i =0; i<tamanho; i++) {
cout << "O numero "<< i +1 << " inserido for: "
<<vetores[&i]<<endl;
}
}
};
int main(){
int tamanhos;
// vetor *varios_vetor;
// varios_vetor = new vetor[tamanho];
cout << "Digite o tamanho do vetor: ";
cin >> tamanhos;
cout <<"Tamanho do vetor: "<< tamanhos << endl;
//vetor::atribuir(int i, int tamanho)
//vetor *varios_vetor;
//varios_vetor = new vetor[tamanhos];
//varios_vetor[tamanhos].atribuir(int *v, int tamanhos);
return 0;
}
You have declared v (and vectors) as an int variable and not as an int pointer or array.
– user4552
How so ta face talking int v; that is not vector ?
– Adriano Carvalho
No, int v is not a vector is just an int variable. Maybe you mean int v[] or int *v. Or maybe you’re thinking of using the vector class.
– user4552