Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-03-15
6
Medium Priority
?
957 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 1000 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 1000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

722 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