Saturday, May 22, 2010

C++: Why is DateTime not working?

The C++ following code (in Visual Studio 2005) generates the error message, "DateTime: undeclared identifier" when i try to compile. Am I using the namespace incorrectly? Why would this not work? Microsoft indicates that DateTime can be used if you use the System.IO namespace...





using namespace System;


using namespace System::IO;


#include "stdafx.h"





void MyProgramDlg :: OnBnClickedUpdate()


{


DateTime x;


}

C++: Why is DateTime not working?
try moving #include "stdafx.h" to the top, above the 'using namespace'.
Reply:First of all, you declare X to be a datetime object now you need to access the date and time





Look in your help file - Can't recall the object names to access but it will be in this format


x.hour x.min


No comments:

Post a Comment