473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

own Vector class

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(d omain),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?
Mar 30 '06 #1
6 1320
You spelled Vector wrong:
static Vektor* get_Vektor(String* e, String* p){
change to:
static Vector* get_Vektor(String* e, String* p){
[==P==]

"Martin S." <Ma*****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com... 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(d omain),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?

Mar 30 '06 #2
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.

"Peter Oliphant" wrote:
You spelled Vector wrong:
static Vektor* get_Vektor(String* e, String* p){


change to:
static Vector* get_Vektor(String* e, String* p){


[==P==]

"Martin S." <Ma*****@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
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(d omain),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?


Mar 30 '06 #3
Martin S. wrote:
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 {...
Mar 30 '06 #4
Martin S. wrote:
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
Mar 30 '06 #5
Tamas Demjen wrote:
Martin S. wrote:
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
Mar 30 '06 #6
Martin S. wrote:
Tamas Demjen wrote:
Martin S. wrote:
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.


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
Mar 30 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alan Benn | last post by:
(VC6) When I use the STL <vector> template as follows: #include <vector> .... vector<CString> m_nameList; // Names of the chips I get these compiler warnings : C:\Program...
11
by: sw | last post by:
Hi, Is it possible to insert a class <vec> which has a vector<double> member, into the vector<vec> veclist for e.g? I've been getting compilation errors when trying to insert using the vector...
9
by: uotani.arisa | last post by:
Hi, Can someone tell me how to declare a pointer to a vector of pointers? I'm just not sure how to do this... I've tried essentially the following: vector<string *> * v; ....
9
by: aaragon | last post by:
I am trying to create a vector of type T and everything goes fine until I try to iterate over it. For some reason, the compiler gives me an error when I declare std::vector<T>::iterator iter;...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
12
by: mast2as | last post by:
Hi everyone I am working on some code that uses colors. Until recently this code used colors represented a tree floats (RGB format) but recently changed so colors are now defined as spectrum....
1
by: krunalbauskar | last post by:
Hi, Explicit instantiation of STL vector demands explicit instantiation of all the templates it using internally. For example - <snippet> #include <iostream> #include <vector>
6
by: Jia | last post by:
Hi all, I have a class foo which has a static vector of pointers of type base class, and a static function to set this vector. #include <iostream> #include <vector> using namespace std;...
4
by: helge | last post by:
What is the best way to implement a vector in space R3, i.e a vector holding three floats, supporting arithmetic operations, dot and cross product etc in c++? is there a standard library class for...
3
by: Ramon F Herrera | last post by:
Newbie alert: I come from C programming, so I still have that frame of mind, but I am trying to "Think in C++". In C this problem would be solved using unions. Hello: Please consider the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.