Define a score class and solve for C

Updated on technology 2024-02-08
3 answers
  1. Anonymous users2024-02-05

    3. All include

    using namespace std;

    class score

    public:

    void set_score();

    void show_score();

    private:

    int num;

    int math;

    int english;

    int main()

    score s1;;;

    return 0;

    void score::set_score()cout<<"Please enter your student number">num;

    cout<<"Please enter a math grade">math;

    cout<<"Please enter your English score">english;

    void score::show_score()

  2. Anonymous users2024-02-04

    The tring class overloads the = operator and provides a copy constructor with char * as the source.

    But you can't use = to char *, the c str() function of the string class can return the first address of its string, and you can assign string to char *

    #include

    using namespace std;

    void main()

  3. Anonymous users2024-02-03

    In fact, there are several key points.

    1。If the number of people cannot be determined in advance, it must be defined by dynamic memory, which is new.

    2。A student's individual grades should be found to form a record, or from the perspective of a 2D array, it is a student record for one line.

    Refer to the program.

    #include

    #include

    using namespace std;

    struct studentscore

    class score;

    score::score(int n)

    score::~score()

    void score::inscore(int num, float mathscore, float programscore, float engscore)

    void score::showscore(int num)

    void score::showallscore()

    int main()

    return 0;

    1。Among them, struct can be regarded as a custom type, which organizes the results of each subject into a separate struct type.

    ClassScore is an application of Dynamic Memory.

    3。All data members (or attributes, i.e., variables listed under private) must be initialized in the constructor(score()).

    4。Because there is dynamic memory, and because the dynamic memory( classscore) is a data member, delete must be done in the destructor (score()), which is the syntax and the specification.

    5。n is the maximum number of student records that can be entered, and currrecord is the number of records that have been entered so far.

    6。In my program, I type the total number of students and the grades of each subject directly in main, but you can also type in from the keyboard, read out from the file, or even get it from the database. If you want your class to be reused in the future, you can't fix the data in the score class, and you need to change it in the future, just change it to main.

    7。If you don't use a struct, you can use a 2D array to record the entire class grade, but it's just a 2D dynamic array, which is more complicated.

Related questions
24 answers2024-02-08

Ten years of life and death, Hengyuanxiang, sheep and sheep. Thousands of miles of lonely graves, laundry detergent with strange strength. Even if you don't know each other, supplement vitamin C, Shierkang. >>>More

9 answers2024-02-08

But think about it the other way, what else can he do for you besides buying breakfast and cooking red bean soup. Can he accompany you home during the New Year's holiday, can he give you a hug when you wake up from a dream in the middle of the night, can he give you a home, can he raise the children with you, think about it, don't go to youth to gamble, because you can't afford to gamble, youth is only once, don't do things that you regret, don't forget, even if you can turn positive, can you guarantee that there will not be a little four, when the time comes, you don't even have his position to accuse him, he will say that you are also a third party.

24 answers2024-02-08

I'm a boy, and what I want to say is: it's not a question of picking a house or a person, the question is whether that girl has the conditions to choose! If you have the conditions, you will pick the one with a house, and enjoy it ready-made; If there are no conditions, people will be picked, and potential stocks will be cultivated. >>>More

9 answers2024-02-08

Xiaobai, Yixuan, Yahan, Hanqing, Congyu, Xinnan, Yanning, Yixuan, Yinghan, Nanlan, Yingyan, Cai'an, Pan'an, Peibo, Xihui, Youhan, Yiqing, Jizhi, Jiyi, Jingdan, Erfu, Qiwei, Yiman, Yaxuan, Hate Butterfly, Zhiqin, Anliu, Youning, Youshan, Lexiang, Xiaoshuang, An Qiao, Xinzhen, Miling, Shuizhu, Youlan, Jinghe, Xuehai, Yuanyang, Daisi, Rudie, Bixia, Fanlian, Yuqin, Crazy Wind, Xiqiao, Zhizhu, Dailu, Yingyun, Aoyun, Miaodan, Wenbai, Danbo, Jingshan, Xiangliu, Panrong, Leng Shan, Youxuan, Xianghan, Yuanzhi, Wanling, Daitian, Luwen, Jingcui, Lecui, Xuetian, Ruodan, Yulan, Luhe, Pansi, Wenfan, Shanyang, Xiayang, Youliu, Youqin, Yannan, Panshuang, Yingxue, Huaimeng, Nanxuan, Cairong, Youxia, Hanyan, Fanliu, Aonan, Jingwei, Hate Huai, Qinghe, Pingshan, Wenshuang, Xiaohai, Miaozhi, Qianhuai, Mifeng, Yuanhan, Jingtian, Dongqin, Chunyi, Wenxuan, Manxuan, Yuqin, Zihan, Mengliu, Caizhen, Pingxuan, Cuiqin, Lubai, Binghan, Chunshan, Daizhen, Yuanzhu, Yidong, Pingyu, Cuishan, Anhan, Huaizhi, Rurou, Daiqiu, Shuizhen, Panyu, Nianshuang, Ling'an, Zuilu, Shubo, Huailu, Hanling, Erxuan, Yingqing, Huaishuang, Baixuan, Manshuang, Guzhen, Daiyun, Yimei, Yiqiao, Danfeng, Wanfeng, Wanhan, Jisi, Yingshuang, Chuhan, Miaoqing, Yilan, Zhihan, Lingshuang, Wenyi, Xiangshan, Xiaorong, Manqing, Tianping, Sidie, Nanfu, Lingzhen, Zhilan, Nianlu, Qiaofan, Peitong, Xin'er, Huanzhi, Caitong, Banbo, Yinghai, Mudie, Lingxuan, Xizhu, Xuewen, Xiao'an, Youzhu, Nanyan, Nanmeng, Feizhen, Yinghan, Lengshuang, Lingfan, Shuilu, Rufeng, Mengdie, Hate Qin, Shanfeng, Miaohe, Bibai, Sichun, Ningxia, Zhiman, Wanrou, Shui Shan, Panbo, Qingyan, Cuixiang, Cherish the Sky, Hanzhi, Hanshan, Qiaolu, Xiangzhu, Tinglan, Banyun, Yiyu, Xinhuai, Youshuang, Xiaohai.

5 answers2024-02-08

1. Infatuated people always hold such thoughts, and even I am moved by myself, what reason does she have not to be moved by me? But perseverance in pursuit only proves that you are a persistent person, nothing more. >>>More