• Register
100 points
7 4

Literals (constants), identifier and (expression) are primary expressions in C++. List of primary expressions is extending. Keywords like this, scope resolution operator, name and the class destructor are included in primary expressions of C++. Let’s discuss error.


We define arrays with [ ] but when we have to pass the array into function; we don’t have to add [ ]. If we include [ ] while passing arrays then the compiler will throw an error.
We only use [ ] while passing arrays when we have to pass a certain element of the array.

For example

int main()
std::string name;
int num, i;
float gradeArray[num];
std::cout << "Please enter the name of the course: ";
std::cin >> name;
std::cout << "Please enter number of students: ";
std::cin >> num;
for (i = 0; i < num; i++)
  {  std::cout << "Studnet " << i << " : ";
    std::cin >> gradeArray[i];
    std::cout << std::endl;
gradeBank t1(name, gradeArray[], num);
  return 0;
Here the statement gradeBank t1(name, gradeArray[], num); contains [] while passing the array. So that is why the compiler is showing an error.


We just have to pass the gradeArray without the [] and that's it.

gradeBank t1(name, gradeArray[], num);

Hope this will help.

100 points
7 4