lundi 29 juin 2015

Change variable type


I'm new in C++ and I'm from Ruby where I can declare a variable and set what I want, for example a class

@variable=MyClass.new

Can do something like that in C++? I have two classes and a global variable declared with the first one set and I want to modify it and set it to the second class, in Ruby I can do something like

@variable=MyClass2.new

My c++ code is like this:

TestClass1 *scene = NULL;
*scene=TestClass1();

And now I try to set it to the second class like I do in Ruby: TestClass2 *newScene=NULL

*newScene=TestClass2()
*scene=*newScene();

error: cannot convert 'TestClass1*' to 'TestClass2*' in assignment

I've search here a lot and in Google but I don't find anything, can someone help me? Thanks you so much


Aucun commentaire:

Enregistrer un commentaire