Question: In my current lab, we are supposed to learning about constructors,classes, utilizing private and public, and how to use git in linux. The assignment is
In my current lab, we are supposed to learning about constructors,classes, utilizing private and public, and how to use git in linux. The assignment is to gather grades and find the average by student name. The problem is when I give the class the name in the main function it gives me this error: conversion from const char [18] to non-scalar type Student requested. I feel like I followed the instructions given well so i dont know what Im doing wrong. Can you please help me?!
MY CODE:
#include
using namespace std;
class Student { public: Student(string name) { student_name = name; }
string name() { return student_name; }
void exam(double grade) { exam_sum += grade; exam_num_grades++; }
double average() { return exam_sum / exam_num_grades; }
private: string student_name; double exam_sum = 0; double exam_num_grades = 0;
};
int main(void) { Student student = "Bjarne Stroustrup"; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
