473,395 Members | 1,577 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,395 software developers and data experts.

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(int 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,dayOfWeek];

}

/*

Error message during compile time

Unhandled Exception: System.NullReferenceException: Object reference not set
to

an instance of an object.

at Month.getDayOfWeek() 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\visual studio
proje

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

Press any key to continue

*/
May 16 '06 #1
1 1202
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(int 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,dayOfWeek];

}

/*

Error message during compile time

Unhandled Exception: System.NullReferenceException: Object reference not set
to

an instance of an object.

at Month.getDayOfWeek() 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\visual 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
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...
10
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...
2
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...
2
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...
5
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...
3
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...
1
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...
10
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...
8
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;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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...

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.