| | |
[c++/visual studio 2003]Array Declaration Issue
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
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++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






