Hi, so I'm fairly new to structs, and what I want to do is read data from a file into a struct. My struct uses 2 classes date and time to read in date and time values, and I've created a Custom Vector class that stores this information in a dynamic array and expands when it needs to.
I'm strugging how to figure out how to read the data into my struct, and for now I am using a test file to test functionality. I'm getting some errors.
Main.cpp:
Code:
#include <iostream>
#include <fstream>
#include "Date.h"
#include "Time.h"
#include "Vector.h"
using namespace std;
typedef struct {
Date d;
Time t;
float speed;
}WindLogType;
int main()
{
Date dTest;
Time tTest;
float speedtest = 52.5;
Vector<WindLogType> windlog;
ifstream infile("testinput.csv");
if(!infile){
cout << "File not found.";
return -1;
};
//int i = 0;
while(!infile.eof()){
infile >> dTest >> tTest >> speedtest;
windlog.add(dTest); //line 42 for error
windlog.add(tTest); //line 43 for error
windlog.add(speedtest); //line 44 for error
}
for(int i = 0; i < windlog.size(); i++){
cout << windlog[i] << " "; //line 50 for error
}
infile.close();
return 0;
}
Errors:
Code:
Line |42|error: no matching function for call to 'Vector<WindLogType>::add(Date&)'|
Line |43|error: no matching function for call to 'Vector<WindLogType>::add(Time&)'|
Line |44|error: no matching function for call to 'Vector<WindLogType>::add(float&)'|
|50|error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'|
Inputfile:
My Vector add method handles any type of data because I've used it in previous exercises so I think the issue lies in how I'm using my struct. Somebody please help!