0
    for(int i = 0; i < classSize; i++){
    cout << "Enter Student Name: ";
    cin >> name;
    cout << "Enter Student Grade: ";
    cin >> grade;

    Student(name, grade);
    newMyClass.push_back(Student);
    cout << endl;
}

The newMyClass.push_back(student); gets an error - expected primary-expression before ")" token. I would upload the entire code to give you a better understanding of the situation but it includes three supporting files as it is a object oriented program.

  • You need to provide a complete sample of code that illustrates your problem (i.e. that other people can compile, and get the same problem). As you have described it, it is not clear whether `Student` is a class or a function, it is not clear what `newMyClass` is. The reason for your problem will vary depending on what those things are. – Peter May 02 '15 at 06:02
  • Yea I figured that as well, its not really clear.. Sorry lol – Mohammed Ibrahim May 02 '15 at 15:56

1 Answers1

1

Student is a class name and not an instance of that class.

Just calling Student(name, grade); creates a class instance that is not named and thus cannot be used anywhere else; a Temporary/Anonymous variable.

When calling newMyClass.push_back(Student); is just syntactically wrong.

You need:

Student student(name, grade);
newMyClass.push_back(student);
bentank
  • 616
  • 3
  • 7