| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1035 人关注过本帖
标题:在线求助大佬
只看楼主 加入收藏
z13009912542
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2020-5-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
在线求助大佬
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册

求解这两道题
搜索更多相关主题的帖子: 在线 
2020-05-20 22:41
吕孟伟
Rank: 8Rank: 8
等 级:贵宾
威 望:27
帖 子:200
专家分:870
注 册:2018-10-4
收藏
得分:20 
1.
程序代码:
#include<iostream>
#include<string>
using namespace std;
class Student{
    public:
        Student();
        Student(string m_name, int m_age, int m_score_C, int m_score_Cpp, int m_score_math);
        Student(const Student& st);
        Student& operator=(const Student& st);
        ~Student();
        void getInformation();
    private:
        string name;
        int age;
        int score_C;
        int score_Cpp;
        int score_math;

};
inline
Student::Student()
{}
inline
Student::Student(string m_name, int m_age, int m_score_C, int m_score_Cpp, int m_score_math)
: name(m_name),age(m_age),score_C(m_score_C), score_Cpp(m_score_Cpp), score_math(m_score_math) 
{}
inline 
Student::Student(const Student& st)
{
    name = st.name;
    age = st.age;
    score_C = st.score_C;
    score_Cpp = st.score_Cpp;
    score_math = st.score_math;

}
inline Student&
Student::operator=(const Student& st)
{
    this->name = st.name;
    this->age = st.age;
    this->score_C = st.score_C;
    this->score_Cpp = st.score_Cpp;
    this->score_math = st.score_math;
    return *this;
}
inline
Student::~Student()
{}
inline void
Student:: getInformation()
{
    cout << "Name:" << this->name << endl;
    cout << "Age:" << this->age << endl;
    cout << "Score of C:" << this->score_C << endl;
    cout << "Score of Cpp:" << this->score_Cpp << endl;
    cout << "Score of math:" << this->score_math << endl;
}
int main(void)
{  
    Student s1("Lmw", 25, 90, 90, 90);
    s1.getInformation();
    Student s2;
    s2 = s1;
    s2.getInformation();
    return 0;
}

借用一下侯捷的话:勿在浮沙筑高台。
2020-05-21 08:40
吕孟伟
Rank: 8Rank: 8
等 级:贵宾
威 望:27
帖 子:200
专家分:870
注 册:2018-10-4
收藏
得分:0 
2.
程序代码:
#include<iostream>
#include<string>
using namespace std;
class Grade{
    public:
        Grade();
        Grade(string m_name, int m_grade = 0);
        Grade(const Grade& gs);
        Grade& operator=(const Grade& gs);
        ~Grade();
        void PrintData();
    private:
        string name;
        int grade;
        bool idPass();
};
inline
Grade::Grade()
{}
inline
Grade::Grade(string m_name, int m_grade)
:name(m_name), grade(m_grade)
{}
inline
Grade::Grade(const Grade& gs)
{
    name = gs.name;
    grade = gs.grade;
}
inline Grade&
Grade::operator=(const Grade& gs)
{
    this->name = gs.name;
    this->grade = gs.grade;
    return *this;
}
inline
Grade::~Grade()
{}
inline bool
Grade:: idPass()
{
    if(this->grade < 60){
        return true;
    }else{
        return false;
    }
}
inline void
Grade:: PrintData()
{
    
    if(idPass()){
        cout << this->name << "'s grade failed!" << endl;
    }else{
        cout << this->name << "'s grade passed!" << endl;
    }
}

int main(void)
{
    Grade g1("Wang", 100);
    Grade g2("Zhang", 90);
    Grade g3("Li", 52);
    Grade g4("Zhao");
    g1.PrintData();
    g2.PrintData();
    g3.PrintData();
    g4.PrintData();
    return 0;
}

借用一下侯捷的话:勿在浮沙筑高台。
2020-05-21 09:07
快速回复:在线求助大佬
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.172128 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved