the class:
public __gc class Vector {
private:
Double y, x, z;
public:
Vector() {
y(0),
x(0),
z(0)
{
}
};
Vektor(Double y, Double x, Double z){
y = x1;
x = x2;
z = x3;
}
Vector(String __gc* strVector); // "123.23,1232.23,4235345."
__property Double get_Y();
__property void set_Y(Double a);
__property Double get_X();
__property void set_X(Double b);
__property Double get_Z();
__property void set_Z(Double c);
};
Now i have another method which tries to return a vector:
class...
static Vektor* get_Vektor(String* e, String* p){
return new
Vektor(Convert::ToDouble(kind),Convert::ToDouble(domain),Convert::ToDouble(category));
}
..
end class
Vektor* obj = new Vektor();
obj = Access::get_Vektor(att1, att2);
Int16 kind = Convert::ToInt16(entity->get_Y()); // error
I got error about "object reference not set to an instance of an object
I think it's about the static method "getVektor()"...
Anyone can help me with this?
Peter Oliphant - 30 Mar 2006 18:09 GMT
You spelled Vector wrong:
> static Vektor* get_Vektor(String* e, String* p){
change to:
> static Vector* get_Vektor(String* e, String* p){
[==P==]
> the class:
>
[quoted text clipped - 45 lines]
> I think it's about the static method "getVektor()"...
> Anyone can help me with this?
Martin S. - 30 Mar 2006 19:05 GMT
Oh sorry my fault. I changed just the Vektor_class from German-->English.
Correct spelling: public __gc class Vector {...
Method has correct Return-type: Vektor.
The problem has to be somewhere else in code.
> You spelled Vector wrong:
>
[quoted text clipped - 55 lines]
> > I think it's about the static method "getVektor()"...
> > Anyone can help me with this?
Martin S. - 30 Mar 2006 19:12 GMT
> Oh sorry my fault. I changed just the Vektor_class from German-->English.
>
> Correct spelling: public __gc class Vector {...
Correct spelling: public __gc class Vektor {...
Tamas Demjen - 30 Mar 2006 19:35 GMT
> Int16 kind = Convert::ToInt16(entity->get_Y()); // error
What is entity? Your error message indicates that entity doesn't point
to any object, so you might have forgotten about creating that object.
Tom
Martin S. - 30 Mar 2006 20:00 GMT
>> Int16 kind = Convert::ToInt16(entity->get_Y()); // error
>
> What is entity? Your error message indicates that entity doesn't point
> to any object, so you might have forgotten about creating that object.
>
> Tom
I create an Instance "obj" from Vektor, att1/att2 are two "Strings".
The Returntype is a Vektor with three elements. In the end I try to pull
out the Y-coordinate with the get-method from Vektor.
Vektor* obj = new Vektor();
obj = Access::get_Vektor(att1, att2);
Int16 kind = Convert::ToInt16(obj->get_Y()); // error
Tamas Demjen - 30 Mar 2006 23:40 GMT
>>> Int16 kind = Convert::ToInt16(entity->get_Y()); // error
>>
[quoted text clipped - 6 lines]
> The Returntype is a Vektor with three elements. In the end I try to pull
> out the Y-coordinate with the get-method from Vektor.
It'd really help if you cut and pasted your code, because your doesn't
even compile. It's full of syntax errors, misplaced { and } symbols, etc.
Here's something that's similar to your code, and it works without an error:
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
public __gc class Vektor
{
private:
Double y, x, z;
public:
Vektor()
: y(0), x(0), z(0)
{
}
Vektor(Double y1, Double x1, Double z1)
: y(y1), x(x1), z(z1)
{
}
__property Double get_Y() { return y; }
__property void set_Y(Double a) { y = a; }
__property Double get_X() { return x; }
__property void set_X(Double b) { x = b; }
__property Double get_Z() { return z; }
__property void set_Z(Double c) { z = c; }
};
public __gc class Access
{
public:
static Vektor* get_Vector(String* e, String* p)
{
return new Vektor(1, 2, 3);
}
};
int _tmain()
{
Vektor* obj = Access::get_Vector(S"", S"");
Int16 kind = Convert::ToInt16(obj->get_Y());
return 0;
}
Tom