473,770 Members | 5,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Stri ng* e, String* p){

return new
Vektor(Convert: :ToDouble(kind) ,Convert::ToDou ble(domain),Con vert::ToDouble( category));
}
...
end class
Vektor* obj = new Vektor();
obj = Access::get_Vek tor(att1, att2);
Int16 kind = Convert::ToInt1 6(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 1345
You spelled Vector wrong:
static Vektor* get_Vektor(Stri ng* e, String* p){
change to:
static Vector* get_Vektor(Stri ng* e, String* p){
[==P==]

"Martin S." <Ma*****@discus sions.microsoft .com> wrote in message
news:81******** *************** ***********@mic rosoft.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(Stri ng* e, String* p){

return new
Vektor(Convert: :ToDouble(kind) ,Convert::ToDou ble(domain),Con vert::ToDouble( category));
}
..
end class
Vektor* obj = new Vektor();
obj = Access::get_Vek tor(att1, att2);
Int16 kind = Convert::ToInt1 6(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(Stri ng* e, String* p){


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


[==P==]

"Martin S." <Ma*****@discus sions.microsoft .com> wrote in message
news:81******** *************** ***********@mic rosoft.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(Stri ng* e, String* p){

return new
Vektor(Convert: :ToDouble(kind) ,Convert::ToDou ble(domain),Con vert::ToDouble( category));
}
..
end class
Vektor* obj = new Vektor();
obj = Access::get_Vek tor(att1, att2);
Int16 kind = Convert::ToInt1 6(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::ToInt1 6(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::ToInt1 6(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_Vek tor(att1, att2);

Int16 kind = Convert::ToInt1 6(obj->get_Y()); // error
Mar 30 '06 #6
Martin S. wrote:
Tamas Demjen wrote:
Martin S. wrote:
Int16 kind = Convert::ToInt1 6(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(Stri ng* e, String* p)
{
return new Vektor(1, 2, 3);
}
};

int _tmain()
{
Vektor* obj = Access::get_Vec tor(S"", S"");
Int16 kind = Convert::ToInt1 6(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
5917
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 Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(39) : warning C4100: '_P' : unreferenced formal parameter
11
6314
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 method push_back() -> c:\program files\microsoft visual studio\vc98\include\xutility(39) : error C2679: binary '=' : no operator defined which takes a right-hand
9
5868
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
8897
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; Any ideas why is tihs happening? The code is as follows: template <class T> struct StdVectorStorage { std::vector<T>* _storage;
24
2961
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 vector<Corres>{ public: void addCorres(Corres& c); //it do little more than push_back function. }
12
2190
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. The size of the vector went from 3 (RGB) to 151 (400 nm to 700 with a sample every 2nm). The variables are using a simple Vector class defined as follow: template<typename T, int Depth> class Vector
1
3074
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
4002
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; class super{ protected:
4
3040
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 this?
3
1685
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 snippet below. I have some objects which are derived (subclassed?, subtyped?) from simpler ones, in increasing size. There is a linear hierarchy. I need to keep them all in some sort of linked list (perhaps std::vector). I could have several
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10053
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.