Solved

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

Posted on 2012-03-15
6
871 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 39

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

747 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

13 Experts available now in Live!

Get 1:1 Help Now