我收到错误#34;没有匹配功能来调用"。给我解决方案

时间:2015-04-03 16:01:33

标签: c++

#include<iostream>

using namespace std ;


class studentpersonal{

    protected :

        int rollno ,age ;
        string name , sex;

        public:

            studentpersonal(int rollno, int age , string name, string gender)
            {

                cout<<"NAME IS  : "<<name;
                cout<<"\nID IS  : "<<rollno;
                cout<<"\nAGE IS  : "<<age;
                cout<<"\nGENDER IS  : "<<gender;


            }



};


class studentmarks : public studentpersonal{

    public:

    studentmarks(int mark1 , int mark2 ,int mark3, int mark4 )
    {
        /*cout<<"marks 1  "<<mark1;
        cout<<"marks 2  "<<mark2;
        cout<<"marks 3  "<<mark3;
        cout<<"marks 4  "<<mark3 ;*/
    }
};

main(){

        studentpersonal ob(6709,19,"WASSAUF","MALE");
    studentmarks ob1(90,95,97,91);

}

调用无函数错误,我该怎么办?

1 个答案:

答案 0 :(得分:0)

班级studentpersonal没有默认构造函数。然而,类student Students的派生类的类studentlog的构造函数试图调用class studentspersonal的默认构造函数。

因为编译器找不到默认构造函数然后它发出错误。

将班级学生作为学生个人的派生类没有任何意义。你可以简单地在班级学生中声明一个有学生标记的数组。