473,763 Members | 6,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

May build, but won't compile..

//These codes will build but wil not compile. I hope someone would know why;
and tell me.

//I got the below error message during compile time

#include "stdafx.h"

#include <string.h>

#include <string>

#using <mscorlib.dll >

#include <tchar.h>

using namespace System;

using namespace std;

__gc class Month

{

public:

Month(int, int); // provide a default value (4 here) if you want

int getDayOfWeek () {return dayOfWeek;}; //line 17
<----------------------------------X

private:

int dayOfWeek ; // This must be initialized with a constant

int weekOfMonth ;

int pDaysOfMonth __gc [,];

};
int _tmain()

{
Month *March;

Console::Write( March->getDayOfWeek() ); // line 31
<-----------------------------------X

return 0;

}

/*************** *************** *************** *************** ********/

Month::Month(in t val1,int val2)

{

Console::Write( S"The default constructor is called\n");

weekOfMonth = val1; // this will be 4 if parameter not specified

dayOfWeek = val2;

pDaysOfMonth = new int __gc[weekOfMonth,day OfWeek];

}

/*

Error message during compile time

Unhandled Exception: System.NullRefe renceException: Object reference not set
to

an instance of an object.

at Month.getDayOfW eek() in c:\documents and settings\owner\ my
documents\visua

l studio projects\okie managed 1\okie managed 1.cpp:line 17

at main() in c:\documents and settings\owner\ my documents\visua l studio
proje

cts\okie managed 1\okie managed 1.cpp:line 31

Press any key to continue

*/
May 16 '06 #1
1 1218
You need to construct the March object. Change the first March line to the
following.

Month* March = new Month(3, 1);

"Allen Maki" wrote:
//These codes will build but wil not compile. I hope someone would know why;
and tell me.

//I got the below error message during compile time

#include "stdafx.h"

#include <string.h>

#include <string>

#using <mscorlib.dll >

#include <tchar.h>

using namespace System;

using namespace std;

__gc class Month

{

public:

Month(int, int); // provide a default value (4 here) if you want

int getDayOfWeek () {return dayOfWeek;}; //line 17
<----------------------------------X

private:

int dayOfWeek ; // This must be initialized with a constant

int weekOfMonth ;

int pDaysOfMonth __gc [,];

};
int _tmain()

{
Month *March;

Console::Write( March->getDayOfWeek() ); // line 31
<-----------------------------------X

return 0;

}

/*************** *************** *************** *************** ********/

Month::Month(in t val1,int val2)

{

Console::Write( S"The default constructor is called\n");

weekOfMonth = val1; // this will be 4 if parameter not specified

dayOfWeek = val2;

pDaysOfMonth = new int __gc[weekOfMonth,day OfWeek];

}

/*

Error message during compile time

Unhandled Exception: System.NullRefe renceException: Object reference not set
to

an instance of an object.

at Month.getDayOfW eek() in c:\documents and settings\owner\ my
documents\visua

l studio projects\okie managed 1\okie managed 1.cpp:line 17

at main() in c:\documents and settings\owner\ my documents\visua l studio
proje

cts\okie managed 1\okie managed 1.cpp:line 31

Press any key to continue

*/

May 16 '06 #2

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

Similar topics

3
3817
by: Phil Frost | last post by:
Greetings all. I'm attempting to embed a python interpreter at a very low level in an OS I am writing. Currently I'm stuck with build issues. Firstly, as there is no working C compiler in our OS, I must cross compile Python. I encountered errors when building Parser/pgen; I got around this by building it nativly and copying it. Hopefully this won't get me later... My current problem (and there are sure to be more ;) ) is when building...
10
2346
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a similar name to the table. Rather than making a long Select Case that could become obsolete if lookup tables are added and the source table of the ListBox is edited I came up with this code.) This code works but of course it gives me build...
2
5211
by: Felix | last post by:
Out of no where I'm starting to get these problems and my Deployment projects won't build anymore. Does anyone have any idea what's causing this? I've tried copying these files from another VS.NET 2003 machine, but it doesn't look like it's working. The only latest change I've made to my machine was the Windows Update as of Feb. 8th, 2005. I notcied it included the .NET 1.1 SP1 and I don't know if this might have any relation? ERROR...
2
1428
by: jr | last post by:
I'm working with VC++ 7, but I think this rather dumb question is C++ related rather than Vis Studio related. If this is the wrong place - apologies, just ignore it! I am trying to use log4cpp, and I downloaded the zip files. When I wish to use it in my code I can #include the required header file. However, when I build I get link problems. This is because the cpp files are not being found or compiled. I can tell VS to look in the...
5
1233
by: JCauble | last post by:
1. We have a web project that has a support dll that uses the following command: HttpContext.Current.Application.ToString(); 2. In our environment we must use a build process that runs from the command line to get things into production, not the IDE. The problem. When we compile the project in the IDE everything works great, the application works the support DLL gets the current context stuff and everything is just fine. However when...
3
5057
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from the network share. It loads in VS2005 fine, and I can edit and save code changes etc, but when I try and Build the solution, I get the following error... An error occured loading a configuration file: Failed to start monitoring
1
4266
by: | last post by:
I'm having a problem finding the cause for this problem. I have a solution in Visual Studio 2005 that contains two projects -- a Web Site and a Class Library. The web site references the class library. After the project became larger, the build process would sometimes fail with no errors. The "quick fix" for this was to rebuild the whole solution and things seemed ok. When this didn't solve the problem any longer, I went to the property...
10
1405
by: Ron | last post by:
I've got this simple program that will not build or run, any idea what I am doing wrong? Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim c As Double = CDbl(txtOrderCost.Text) Dim r As Integer = CInt(txtMonthlyDemand.Text) Dim p As Double = CDbl(txtPartCost.Text) Dim f As Double = 0.15 Dim h As Double = p * f
8
1386
by: Alexander Llew Wykel | last post by:
I have a project where I load some of my assemblies dynamically, I'm using a venders product where he loads some assemblies dynamically. He loads two assemblies that both share a common name; however have different public keys and version numbers. I receive an error when I compile the my assembly (the dynamic one) it tells me to us the vendors other version of the product, Which is completely wrong since the items I need aren't even in...
0
9386
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
10144
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
9997
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
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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.