CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    15

    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;

    }

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Error C4430: missing type specifier - int assumed.

    1. Please use Code tags.
    2. Where and how is GetAge() declared?
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    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.

  4. #4
    Join Date
    Aug 2009
    Location
    Romania->Felnac
    Posts
    48

    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'
    //...

  5. #5
    Join Date
    Oct 2010
    Posts
    15

    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;
    
    	}

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Error C4430: missing type specifier - int assumed.

    This confirms what I've posted above:

    Quote Originally Posted by Eri523 View Post
    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.

  7. #7
    Join Date
    Oct 2010
    Posts
    15

    Re: Error C4430: missing type specifier - int assumed.

    Thank You! I am trying to learn all the ins and outs of how to post

  8. #8
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Error C4430: missing type specifier - int assumed.

    Quote Originally Posted by newbe1 View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured