default constructor

my default constructor is giving me problems.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 #include <iostream>
#include <string>
using namespace std;

class Course
{
    private:
    string ID;
    int credits;
    char grade;
    
    public:
    Course()
    {
        ID= "CS116";
        credits="89";
        grade="B";
    }
    
    Course(string Id,int Cdit,char G)
    {
        ID=Id;
        credits=Cdit;
        grade=G;
    }
    
    void setID(string id);
    string getID();
    void setcredits(double Credits);
    double getcredits();
    void setgrade(char Grade);
    char getgrade();
    
    
};
void Course::setID(string id)
{
    ID=id;
}

string Course::getID()
{
    return ID;
    
}
void Course::setcredits(double Credits)
 {
     credits=Credits;
 }
double Course::getcredits()
{
    return credits;
}
void Course::setgrade(char Grade)
{
    grade=Grade;
}
char Course::getgrade()
{
    return grade;
}

int main()
{
    
}
you cannot assign a string to an integer. int x = 89; //ok. int x = "89"; //not ok.

char is really a type of int, and you cannot assign a string to a char either.
char x = "b"; // no good. char x = 12; //ok. char x = 'b'; //ok. note single quotes is one char, double quotes is one string.

i re did this , thank you

public:
Course()
{
ID= "CS116";
credits=89;
grade='B';
}
Topic archived. No new replies allowed.