473,398 Members | 2,403 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,398 software developers and data experts.

An unhandled exception of type 'System.NullReferenceException' occurred

Hi i am a novice in C++ programming and encountered the following
problem without headway - a popout appeared after successful
compilation and linking with:
"An unhandled exception of type 'System.NullReferenceException'
occurred in rational.exe
Additional information: Object reference not set to an instance of an
object."

On pressing break, the code stopped at the fract[0] which is a private
class Rational member:

int* rational::setrational(int n, int d)
{
div_t div_result;
const int size = 3;
if (n > d )
{
div_result = div(n,d);
fract[0]= div_result.quot; --> code execution stopped here
fract[1]= div_result.rem;
fract[2]= d;
}
else
{
fract[0]= 0; <---- or here.
fract[1]= n;
fract[2]= d;

};

return fract;

Can anyone help? thanks

Oct 27 '05 #1
3 3678
Ian
er*********@gmail.com wrote:
Hi i am a novice in C++ programming and encountered the following
problem without headway - a popout appeared after successful
compilation and linking with:
"An unhandled exception of type 'System.NullReferenceException'
occurred in rational.exe
Additional information: Object reference not set to an instance of an
object."

On pressing break, the code stopped at the fract[0] which is a private
class Rational member:

Does the array fract exist? Has it been initialised, or simply declared?

Ian
Oct 27 '05 #2
er*********@gmail.com wrote:
Hi i am a novice in C++ programming and encountered the following
problem without headway - a popout appeared after successful
compilation and linking with:
"An unhandled exception of type 'System.NullReferenceException'
occurred in rational.exe
Additional information: Object reference not set to an instance of an
object."

On pressing break, the code stopped at the fract[0] which is a private
class Rational member:

int* rational::setrational(int n, int d)
{
div_t div_result;
const int size = 3;
if (n > d )
{
div_result = div(n,d);
fract[0]= div_result.quot; --> code execution stopped here
fract[1]= div_result.rem;
fract[2]= d;
}
else
{
fract[0]= 0; <---- or here.
fract[1]= n;
fract[2]= d;

};

return fract;

Can anyone help? thanks


Presumably fract is a null pointer. How it got to be a null pointer and
what it should be instead is impossible to tell from the code posted.

john
Oct 27 '05 #3
Thanks John & Ian. Will follow your suggestion to check on the code...

Oct 28 '05 #4

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

Similar topics

1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
0
by: Rafiq Ganaie via .NET 247 | last post by:
HI, I am working on a search application in C#.It is a multithreaded application.it simply takes a URL,Downloads the page using WebRequest and WebResponse classes.Unfortunately it is throwing...
3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
3
by: cristiank | last post by:
hi everybody, I need to clear something out, does anybody have ever encountered such an exception until now : "Un unhandled exception of type System.NullReferenceException occurred in...
3
by: juli | last post by:
Hello! I keep getting this error: An unhandled exception of type 'System.NullReferenceException' occurred Additional information: Object reference not set to an instance of an object. I am...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
1
by: mike | last post by:
My program is crashing, but it doesn't crash on a single line of code. Below is what the output tab displays. I have no idea where to start inorder to debug this problem. Is there any suggesstions...
9
by: Supra | last post by:
i got error problem.......... An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll Additional information: Object reference not set to an instance of...
1
by: Pedro Dinis | last post by:
i have this class library that connects to the database(see appconfig below) compiling 0 errors but when its running i amhaving this error An unhandled exception of type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.