This has been taking me forever to figure out and i have researched so many different examples, but some seem so convoluted and have extra steps in them for reasons A,B,C….. This is what I need-Let’s say you have a string and we will call it string A
String A = “I<Like<Butterscotch<candies<so<much”
So the delimiter of course is ‘<‘
How do I parse this string to take out the delimiters? I then have to make objects of these strings and add them to an array of pointers.
Please see an example below:) Please ignore all the directives at the top. I hate guessing what I need and don’t need so I started including every one I need in all files (except for including files within others). I have spent 6+ hours researching parsing and I am getting nowhere, so I am officially done for the night…..
I am also confused by pointers I guess because I thought the line below would be a pointer to take my data from the Student class in my student header file and have it create an Array of Pointers, which I will then fill with objects using the ‘add’ method below…….. but it tells me-Cannot initialize a member subobject of type ‘Student *’ with an rvalue of type ‘string *’ (aka ‘basic_string<char> *’)…. I feel like I am taking a step forward then hitting a wall and bouncing back 2 steps while trying to learn this material…..
Student* classRosterArray = new string[5];
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <print>
#include <iomanip>
#include "student.hpp"
using namespace std;
class Roster
{
private:
// Array of pointers, size = 5-- I thought I was supposed to use a pointer to reference the Student class.... and call the new array which we are adding objects into classRosterArray?
Student* classRosterArray = new string[5];
//string* classRosterArray = new string[5]; --Is this what is needed??
public:
void parse(string row);
void add(string studentId,
string firstName,
string lastName,
string emailAddress,
int age,
int daysToComp3Course,
DegreeProgram degreeProgram);
};
user25485370 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.