myclass1 class1 = new myclass1;
myclass1 class2;
class2.CopyObject(class1);
delete class1; //This exits the program for no reason at all, no message or anything.
myclass1::CopyObject(myclass1 m)
{
x = m.x;
y = m.y;
z = m.z;
...
}
myclass1 class1 = new myclass1;
myclass1 class2;
class2.CopyObject(class1);
delete class1; //This exits the program for no reason at all, no message or anything.
myclass1::CopyObject(myclass1 m)
{
x = m.x;
y = m.y;
z = m.z;
...
}
myclass1* class1 = new myclass1(); // default constructormyclass1* class2;class2.CopyObject(class1);delete class1;//------------- in the other filevoid myclass1::CopyObject(myclass1* m){x = m->x;y = m->y;z = m->z;}
Quote:Original post by stormrunnermyclass1* class1 = new myclass1(); // default constructormyclass1* class2;class2.CopyObject(class1);delete class1;//------------- in the other filevoid myclass1::CopyObject(myclass1* m){x = m->x;y = m->y;z = m->z;}
Quote:Original post by silvermaceQuote:Original post by disanti
If there is a class, it is C++.
Java isn't C++.
Quote:Original post by daeridQuote:Original post by silvermaceQuote:Original post by disanti
If there is a class, it is C++.
Java isn't C++.
True. However, Java doesn't have the :: operator, does it?
Quote:Original post by stormrunner
indeed. the delete operator only works with pointers, as does the new operator. applying them the way you do is considered very unfortunate. instead, it should be implemented something like this :myclass1* class1 = new myclass1(); // default constructormyclass1* class2;class2.CopyObject(class1);delete class1;//------------- in the other filevoid myclass1::CopyObject(myclass1* m){x = m->x;y = m->y;z = m->z;}
the * indicates a pointer object (read the referenced tutorial). and make sure a return type is infront of your function (should be void). however, you would usually not be using a "CopyObject" method, implement it through either a copy constructor or overloading the '=' operator.
<edit :: fixed late-night grammatical mistakes>