Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2006

Tip: Looking for answers? Try searching our database.

May build, but won't compile..

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Allen Maki - 16 May 2006 07:18 GMT
//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

*/
mccoyn - 16 May 2006 13:51 GMT
You need to construct the March object.  Change the first March line to the
following.

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

> //These codes will build but wil not compile. I hope someone would know why;
> and tell me.
[quoted text clipped - 87 lines]
>
> */

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.