This is my code

class AddResult
string ar_stu_id, ar_mod1, ar_mod2, ar_mod3, ar_mark1, ar_mark2, ar_mark3;
void addresult();
    AddResult(string, string, string, string, string, string, string)
    cout<<ar_stu_id <<" " << ar_mod1 <<" " << ar_mod2 <<" " << ar_mod3 <<" " << ar_mark1 <<" " << ar_mark2 <<" " << ar_mark3;
void AddResult::addresult()
char con;

ofstream stu_mark;
cout<<"Please insert the following information.\n\n"; ("StudentMarks.txt", fstream::in | fstream::out | fstream::ate | ios::app); 

cout<<"Student ID\n";
getline(cin, ar_stu_id);
cout<<"Module 1"<<endl;
getline(cin, ar_mod1);
cout<<"Mark 1"<<endl;
getline(cin, ar_mark1);
cout<<"Module 2"<<endl;
getline(cin, ar_mod2);
cout<<"Mark 2"<<endl;
getline(cin, ar_mark2);
cout<<"Module 3"<<endl;
getline(cin, ar_mod3);
cout<<"Mark 3"<<endl;
getline(cin, ar_mark3);

    AddResult(ar_stu_id, ar_mod1, ar_mod2, ar_mod3, ar_mark1, ar_mark2, ar_mark3);

stu_mark << ar_stu_id << "    ";
stu_mark << ar_mod1 << "       ";
stu_mark << ar_mark1;
stu_mark << "         " << ar_mod2 << "       ";
stu_mark << ar_mark2;
stu_mark << "        " << ar_mod3 << "      ";
stu_mark << ar_mark3 << endl;

cout<<"Continue? (Y/N)";
    AddResult obj; <----no default constructor in Class AddResult
else if (con=='n')
    Admin obj;;

Anyone can help me?

Edited 4 Years Ago by Vegito1991

Automagic synthesis of a default constructor is disabled when you provide any explicit constructor. If that explicit constructor has arguments and not all of them are defaulted, then your class will not support a default constructor unless you explicitly define one.

Your class has a seven argument constructor, so the default construction syntax won't work. There are quite a few problems with your code, but that's the exact cause of the error you're receiving.

If you describe what the program is supposed to be doing, I may be able to help you redesign things to work better.

actually im doing the assignment and this code just part of my program.
i wan to display the variable that i enter, thats my problem now.

This article has been dead for over six months. Start a new discussion instead.