Good evening,
I've been trying to write a linked list code for a while today, where I have two structs, one calling another. I also have a function, but attempting to pass the struct as an argument for the function returns an error.
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
usingnamespace std;
void push_front(double pop, string name, Node*& n, Node*& t); //Error here for both n and t
void push_front (double pop,string name, Node*& n, Node*& t)//Error here as well
{
n= new Node;
n->ctry.population=pop;
n->ctry.name=name;
t->next=n;
t=t->next;
}
int main()
{
struct Country {
string name;
double population;
};
struct Node {
Country ctry;
Node * next;
};
Node * world;
Node* n;
Node* t;
t=n;
/*blah;
blah;
blah;
*/
return 0;
}
The error reads as the title, saying that Node was not declared,
What gives?
(This is beginner level stuff, I am trying to make a simple linked list with data read from a file, but I did not reach that part of the code yet)
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
usingnamespace std;
struct Country {
string name;
double population;
};
struct Node {
Country ctry;
Node * next;
};
void push_front(double pop, string name, Node*& n, Node*& t); //Error here for both n and t
void push_front (double pop,string name, Node*& n, Node*& t)//Error here as well
{
// ...