I want to write a program that calculates a final grade of a class based on weighted averages, and I'm in the stage of prompting the user for the names of each category (eg. 'Homework', 'Quiz', etc). I have it set up to ask the user how many categories they have, and then ask them each one individually, and then save each category name as a string into an array element. I know its probably easier to use vector class, but I'd like to do it this way if at all possible.
#include <cmath>
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
cout << "How many grade categories are there for this class? ";
cin >> categories;
int * categorynames = new int[categories];
for (int i(0); i < categories; i++)
{
string text;
cout << "Name of category: ";
getline(cin, text);
categorynames[i] = text;
}
When I compile, I'm getting an error of "cannot convert std::string to int in assignment."
Can anyone help, please?