| | |
[c++/visual studio 2003]Array Declaration Issue
![]() |
•
•
Join Date: Nov 2006
Posts: 2
Reputation:
Solved Threads: 0
I have the following code:
Upon compilation I recieve these errors:
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2059: syntax error : '{'
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2143: syntax error : missing ';' before '{'
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2143: syntax error : missing ';' before '}'
I'm not sure what I am doing wrong here, I have only been working with c++ for a little while now and have searched everywhere to find nothing already posted on the web. Any help on this issue is greatly appreciated.
Denn0069
c Syntax (Toggle Plain Text)
class date { private: unsigned int nDay,nMonth,nYear; static unsigned int nMonthArr[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; //LINE 36 ...
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2059: syntax error : '{'
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2143: syntax error : missing ';' before '{'
n:\courses\8110\Labs\Lab7b\Lab7b.cpp(36) : error C2143: syntax error : missing ';' before '}'
I'm not sure what I am doing wrong here, I have only been working with c++ for a little while now and have searched everywhere to find nothing already posted on the web. Any help on this issue is greatly appreciated.
Denn0069
Last edited by denn0069; Nov 22nd, 2006 at 9:24 pm.
you can't initialize arrays like that in the class definitions. Initialize it in the *.cpp file just like you would any other global array.
C++ Syntax (Toggle Plain Text)
// *.h file class date { private: unsigned int nDay,nMonth,nYear; static unsigned int nMonthArr[12]; //LINE 36 ... // *.cpp file unsigned int Date::nMonthArr[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; //LINE 36
Last edited by Ancient Dragon; Nov 22nd, 2006 at 11:37 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- ASP .NET C# SQL on Visual Studio 2003, help? (ASP)
- Visual Studio 2003 + Wingdings? (Windows Software)
- Problem with visual Studio 2003 c# (C#)
- TechNet TV - Visual Studio 2003 ....... (VB.NET)
- Using Crystal Reports XI with Visual Studio .NET 2003 (VB.NET)
- how to update visual studio .net 2003 (ASP.NET)
Other Threads in the C++ Forum
- Previous Thread: Capture system date?
- Next Thread: Program 2 copy log file frm database
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ char class classes code coding compaitibility compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error factorial file floatingpoint forms fstream function functions game givemetehcodez graph guessing gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix maze memory multiple net news node oop output payment pointer practice problem program programming project projectassignmenthelp protection python random rank read recursion reference rpg skills string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






