473,594 Members | 2,713 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 1212
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
3810
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
2313
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
5198
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
1420
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
1230
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
5044
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
4243
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
1392
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
1372
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
7946
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
7876
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
8251
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...
1
8003
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
8234
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6654
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...
1
5739
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
3859
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...
1
2385
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

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.