The code has several small problems, I don’t even know what to say to clarify the question because I didn’t understand it, I don’t even know if you have a specific question. There was a code played without much criterion and that was not even to be tested. Note that I didn’t change anything to make it work what was asked, I was fixing basic syntax errors and what else could be a doubt is the change of the operator .
for the operator ->
in the this
.
#include <string>
using namespace std;
class Teste2 {
int x;
int y;
public:
Teste2(int x, int y) {}
};
class Testando {
Teste2 *teste2;
public:
Testando(Teste2 *teste2) {}
};
class Teste : public Testando {
string nome;
int numero;
public:
//Supondo que Teste2 teste2 foi instanciado na Classe Testando
Teste(Teste2 *teste2, string nome, int numero) : Testando(teste2) {
this->nome = nome;
this->numero = numero;
}
};
int main() {
auto teste = Teste(new Teste2(1, 2), "joão", 1);
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
To tell you the truth I think that most of these codes don’t make sense and I don’t believe that this is teaching anything really useful.
I didn’t understand what you want, nor the goal, mainly, but not only, because it lacks context.
– Maniero
@mustache on the other question was a
string
now a class or type Test2, it was clear or not?– Vale
It’s hard to help you because even though you say it’s going to change, you always put everything in half, no context, no organization, we get lost without even knowing what the code should do and have to keep completing, tidying, until the code compiles. Have you read this? http://answall.com/help/mcve. The code must be compileable at least in the part that is not part of the doubt. Playing code anyway makes any help difficult.
– Maniero
@bigown understand, that this code create on the spot here on the site I have not ready, but I believe it is the libraries that are missing.
#include<Teste2>
– Vale