Trying to call a function

So I'm trying to call this function and I keep getting an error I'm not sure how to fix. This is the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct Country
 {
  string  name;
  double  population;
 };
struct Node 
 {
  Country ctry;
  Node *  next;
 };
Node * world;

void push(Country data, Node*& list);

int main ()
{
	Country item;
	Node list;
	
	push(item, list);
	return 0;
}


The error is in push(item, list);
Last edited on
If the code above is everything you have, then you got too many problems.

Firstly, line 3, you didn't declare the header <string> and using namespace std.
Secondly, line 13, you really should learn about the pointer before you intend using it.
Next, line 18, you can add a var into a pointer paramenter.
Finally, line 20, you just declared the push() function. You need to define it too.

Here is my solution:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string>
#include <iostream>
using namespace std;

struct Country
 {
  string  name;//Problem 1
  double  population;
 };
struct Node 
 {
  Country ctry;
  Node *  next;
 };

void push(Country, Node*);//Problem 2

int main ()
{
	Country item;
	Node* list; //Problem 3
	
	push(item, list);//problem4
	return 0;
}

void push (Country data, Node* list) {
    cout << "Do something about it in here";    
}
Last edited on
Topic archived. No new replies allowed.