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]

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

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

Edited 5 Years Ago by Narue: added formatting and code tags

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.

This question has already been answered. Start a new discussion instead.