Im having a problem with error message c4430 according to MSDN the warning is created when an int is not declared. Overlooking ,y code I can't find the problem is there something I am missing? here is the code

#include<iostream>
#include<string>
using namespace std;
class student
{
public:
	~student();
	student();
	student(string n,int i);
	void student_name();
	int student_id();
	void view_name();
	int view_id();
private:
	string sName;
	int sId;
};
student::student()
{
	string sName="NewStudent";
}
student::student_id()
{
	int sId=000;
}
student::student(string n, int i)
{
	n=sName;
	i=sId;
}
void student::student_name()
{
	cout<<"What is the Student's Name?"<<endl;
	cin>>sName;
	cout<<"What is the Student's Identification Number?"<<endl;
	cin>>sId;
}

Two things about the code jump out

student::student_id()
{
   int sId=000;
}
student::student(string n, int i)
{
   n=sName;
   i=sId;
}

In the first function above, you are declaring sId, where it's already a datamember of the class. And you don't need a constructor for the data member, you have a constructor for the whole class.

In the second function, you have your assignment statements backwards. Remember LHS <-- RHS

Also, to post code here, use the tags thusly

[code]

your code goes here

[/code]

which line did the error occur on ? And make sure spelling and capitalization are all consistent.

For future questions, please copy and paste the error in its entirety instead of paraphrasing. This is what the error actually says, which is different from your interpretation:

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Going to the line that's specified, you find yourself at the definition of student_id (which returns an int in the declaration):

student::student_id()
{
	int sId=000;
}

Notice that there's no return type in the definition, a feature called implicit int which is not supported by C++. You can fix the error by explicitly stating the return type. A further error will be flagged because the body of this member function is nonsensical. It can be fixed as well:

int student::student_id()
{
	return sId;
}

Thank You all for your help It was very useful

I get the same error when building and running this code below - can anyone help ?

#include <iostream>
using namespace std;

int main()
{
    int count;
    float time, mass;
    double distance, velocity, force, initial_velocity, acceleration;

    cin>> mass;
    force = mass * acceleration;
    count = (78-5 % 3 * 4 + 0);

    count++;
    count--;
    ++count;
    --count;
    cout << count;

    velocity +=distance;
    velocity *=distance;

    distance = initial_velocity * time + 0.5 acceleration*(time*time);
    velocity = distance / time;
    cout << velocity <<"\n";
}

I get the same error when building and running this code below - can anyone help ?

#include <iostream>
using namespace std;

int main()
{
    int count;
    float time, mass;
    double distance, velocity, force, initial_velocity, acceleration;

    cin>> mass;
    force = mass * acceleration;
    count = (78-5 % 3 * 4 + 0);

    count++;
    count--;
    ++count;
    --count;
    cout << count;

    velocity +=distance;
    velocity *=distance;

    distance = initial_velocity * time + 0.5 acceleration*(time*time);
    velocity = distance / time;
    cout << velocity <<"\n";
}

0.5 acceleration isn't meaningful. You probably meant to place an operator of some sort between those two operands.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.