-
November 4th, 2010, 05:37 PM
#1
Error C4430: missing type specifier - int assumed.
Can someone help me to understand what is wrong with this code. I am receiving the error
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
class Numbers
{
public:
Numbers(void);
~Number(void);
int Number::GetNumber() const;
};
#include "Number.h"
#include <iostream>
using namespace std;
Number::Number(void)
{
}
Number::~Number(void)
{
}
Number::GetAge()const The error points to these two lines of code
{
int iNumbers = 0;
cout << "Enter the number ";
cin >> iNumbers;
return iNumbers;
}
-
November 4th, 2010, 05:50 PM
#2
Re: Error C4430: missing type specifier - int assumed.
1. Please use Code tags.
2. Where and how is GetAge() declared?
Victor Nijegorodov
-
November 4th, 2010, 05:53 PM
#3
Re: Error C4430: missing type specifier - int assumed.
The offending line is missing the int type specifier right at the beginning.
BTW, is the name of your class Number or Numbers? Or are this two distinct classes?
And in the offending line you are defining a member function named Number::GetAge() while your class declaration declares one named Number::GetNumber().
All that leads me to the conclusion that it is not your actual code that you've posted here, otherwise you certainly would have got some more errors. And you definitely should post your actual code here.
And please use code tags.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
November 4th, 2010, 05:55 PM
#4
Re: Error C4430: missing type specifier - int assumed.
The code is not complete, not the error message (you didn't told us the variable name)
But most likely the error is about this miss-match:
Code:
class Numbers //here you have the 's'
{
public:
Numbers(void); // again with 's'
~Number(void); // without 's'
//...
-
November 4th, 2010, 06:11 PM
#5
Re: Error C4430: missing type specifier - int assumed.
Here is the code.
Code:
#pragma once
class Numbers
{
public:
Numbers(void);
~Numbers(void);
int Numbers::GetNumber();
private:
int iNumber;
};
#include "StdAfx.h"
#include "Numbers.h"
#include <iostream>
using namespace std;
Numbers::Numbers(void)
{
}
Numbers::~Numbers(void)
{
}
Numbers::GetNumber()
{ //This is where the error points to
int number=0;
cout << "Enter a Number ";
cin >> number;
return number;
}
-
November 4th, 2010, 06:17 PM
#6
Re: Error C4430: missing type specifier - int assumed.
This confirms what I've posted above:
Originally Posted by Eri523
The offending line is missing the int type specifier right at the beginning.
Bravo for the code tags.
But obviously that are two files (a .h and a .cpp) and should have been posted in separate code blocks. It is not too bad in that simple case, but the more complex the code gets, the more the reader would benefit from that.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
November 4th, 2010, 06:36 PM
#7
Re: Error C4430: missing type specifier - int assumed.
Thank You! I am trying to learn all the ins and outs of how to post
-
November 5th, 2010, 12:15 PM
#8
Re: Error C4430: missing type specifier - int assumed.
Originally Posted by newbe1
Here is the code.
Code:
#pragma once
class Numbers
{
public:
Numbers(void);
~Numbers(void);
int Numbers::GetNumber();
private:
int iNumber;
};
#include "StdAfx.h"
#include "Numbers.h"
#include <iostream>
using namespace std;
Numbers::Numbers(void)
{
}
Numbers::~Numbers(void)
{
}
Numbers::GetNumber()
{ //This is where the error points to
int number=0;
cout << "Enter a Number ";
cin >> number;
return number;
}
"GetNumber" is not a member of your class, and it has no return type.
Viggy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|