Solved

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

Posted on 2012-03-15
6
890 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

821 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