// manages parsing
#pragma once
#include <iostream>
#include <string>
class Scheme {
public:
Scheme(std::string filename = "ta031", short pivot = 0, short neighbour = 0, short init = 0);
std::string filename;
short pivot;
short neighbour;
short init;
// this will parse the received input
void parse_input(int count, char* arg[]);
};
Instead of redeclaring your struct, just include the header.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//parser.cpp
//#pragma once //you would not include cpps
#include "parser.h"
void Scheme::parse_input(int count, char* arg[]) {
//...
}
Scheme::Scheme(std::string filename, short pivot, short neighbour, short init)://you never defined this
filename(filename),
pivot(pivot),
neighbour(neighbour),
init(init)
{}
This is because filename is already a member of Scheme. You need to use a different name. I like to put a '_' in front of the variable name in my function argument list.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//parser.cpp
//#pragma once //you would not include cpps
#include "parser.h"
void Scheme::parse_input(int count, char* arg[]) {
//...
}
Scheme(std::string _filename = "ta031", short _pivot = 0, short _neighbour = 0, short _init = 0):
filename(_filename),
pivot(_pivot),
neighbuor(_neighbour),
init(_init)
{}
No, that shouldn't matter. It is not in any way ambiguous
I updated the post, it should work now.
I forgot the Scheme:: at the beginning, that tells that it is a method of that class.
Also, default values can't be in declaration and definition. Prefer to put them in the header.