Solved

C++, Enum, missing type specifier, int assumed.

Posted on 2012-03-15
6
879 Views
Last Modified: 2012-03-15
Hi, in a VC++ 6.0 project, I had the following, which compiled and worked as desired:

enum CameraStatus
{
      CAMERA_STOPPED = 0,
      CAMERA_PREVIEW ,
      CAMERA_PAUSED ,
      CAMERA_CAPTURE_REQUESTED
};

..

virtual SetStatus(CameraStatus a_Status){ m_Status = a_Status;};
..

CameraStatus m_Status;

---------
But in Visual Studio 2010, I now get an error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


How do I explicitly apply the int type to my enumeration?

Thanks
0
Comment
Question by:PMH4514
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 250 total points
ID: 37725155
enum CameraStatus : int
{
      CAMERA_STOPPED = 0,
      CAMERA_PREVIEW ,
      CAMERA_PAUSED ,
      CAMERA_CAPTURE_REQUESTED
};
0
 

Author Comment

by:PMH4514
ID: 37725187
I had tried that actually. I still get the error:

 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

on this line:

virtual SetStatus(CameraStatus a_Status){ m_Status = a_Status;};
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 37725232
The error message targets the missing return type in your statement - try changing

virtual SetStatus(CameraStatus a_Status){ m_Status = a_Status;};

to

virtual void SetStatus(CameraStatus a_Status){ m_Status = a_Status;}; // note 'void'
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:PMH4514
ID: 37725245
what's interesting is that I have other similar constructs in the code and the compiler isn't complaining.
0
 
LVL 86

Expert Comment

by:jkr
ID: 37725265
Yes, it's only the missing return type, VC++ 6 was a lot more forgiving about things like that ;o)
0
 

Author Comment

by:PMH4514
ID: 37725269
ahh yes, jkr, you are correct sir.  thank you!

I guess I did specifically ask "How do I explicitly apply the int type to my enumeration?" and  #ged325 did specifically answer that, despite my real question being the compile error.

so I'll bump points and award you both.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now