I am having difficulty executing a program that I wrote with structs. My program has a header file, an initialization file, and a main file. When I compiled it, the compiler complained and later I found out that I forward declared my struct name as Company but initialized it using company so I changed it to Company but still the compiler complains after I did this. How can I fix this? Any help will be greatly appreciated. Below is my code for my three files:
structs.h:
#ifndef STRUCTS_H
#define STRUCTS_H
struct Company{
double salary;
int workers;
int bosses;
}
#endif
initialization.cpp:
Company a = {1200340.99, 30000, 3};
Company b = {500320.85, 5000, 2};
main.cpp:
#include <iostream>
#include "structs.h"
void PrintInfo(Company company){
using namespace std;
cout << "salary: " << Company.salary << endl;
cout << "workers: " << Company.workers << endl;
cout << "bosses: " << Company.bosses << endl;
}
int main(){
PrintInfo(a);
PrintInfo(b);
return 0;
}