classes

create a called student with the data members: Name Idno, English Marks, Maths Marks and Physics Marks
Member functions:

void inputdetails()
float calculate_average()
void print details()

use constructor instead of inputdetails() to initialize the values.

this is what i have so far but its not compiling

#include <iostream>

using namespace std;

class student
{
private:
string Name;
int idNo;
double English;
double Maths;
double Physics;

public:
student();
void inputDetails()
float calculateAverage()
void printDetails()
};

student::student()
{
Name = " ";
idNo = "0";
English = "0.0";
Maths = "0.0";
Physics = "0.0";
};

void student::inputDetails()
{
cout<<"Enter name";
getline(cin,Name);
cout<<"Enter id#";
cin>>idNo;
cout<<"English Marks";
cin>> English;
cout<<"Maths Marks";
cin>> Maths;
cout<<"Physics Marks";
cin>> Physics;
a) Use Code tags.
b) You have no main.
c) Functions don't need a ';' after their closing '}'. (See student::student().)
d) Functions need a closing '}'. (See student::inputDetails().)

Topic archived. No new replies allowed.