I was trying to run this simple block of code and I got the error: expression must have class type for tom.name
and tom.id
. What have I done wrong here?
#include <iostream>
#include <string>
using namespace std;
class Student
{
string name;
int id;
int age;
};
int main()
{
Student* tom = new Student;
tom.name = "tom";
tom.id = 1;
}