calling string from class

I keep getting an error for the names(John, Smith) saying that they are const char and not string and the constructors does not match the argument list. How do i fix that?



this is how I called in in the class.
class Student
{
private:
string fname;
string lname;
int ID;
public:
static int numberOfStudents;
void student();
void student(string, string, int)

and this is what i wrote in main

Student st1("John", "Smith", 1234), st2("Eric", "Evans", 2345), st3("Gina", "Kim", 5442), st4;
Next time please post your code using the code tags under Format.

Since the Student class has a constructor using strings, you should pass it strings and not const char strings.
Where are these constructors you mention? I see two functions named student in the Student class but no constructors. Remember C++ is case sensitive, student is not the same as Student. Also constructors don't have a return type.

Last edited on
Topic archived. No new replies allowed.