I started building a project on my computer. the project compiled on my computer, but when i copied it to another computer it had fatal errors(its work on visual c++ express 2010). its still small so i will just copy all the project.
source file->main.cpp:
#include <iostream>
#include <string>
using namespace std;
#include "List.h"
void products_menu(){
return;
}
void stores_menu(){
return;
}
void costumers_menu(){
return;
}
int main(){
int option;
Products a;
do{
cin>>option;
if(option==1)
products_menu();
//option funcion
if(option==2)
stores_menu();
//option funcion
if(option==3)
costumers_menu();
//option funcion
}while(option!=4);
}
source file->List.cpp:
#include <iostream>
#include <string>
using namespace std;
#include "List.h"
void products_menu(){
return;
}
void stores_menu(){
return;
}
void costumers_menu(){
return;
}
int main(){
int option;
Products a;
do{
cin>>option;
if(option==1)
products_menu();
//option funcion
if(option==2)
stores_menu();
//option funcion
if(option==3)
costumers_menu();
//option funcion
}while(option!=4);
}
Header files->List.h:
#pragma once
#ifndef LIST_H
#define LIST_H
#include <string>
using namespace std;
class Products{
private:
typedef struct node{
int id;
string name;
int price;
node* next;
};
//typedef struct node* nodePtr;
//nodePtr head;
public:
Products();
//~Products();
void addProduct(int id, string& name, int price);
void updateNameProduct(int id, string& oldName, string& newName);
void updatePriceProduct(int id, int oldPrice, int newPrice);
void printProducts();//
};
Products* first;
Products* nodePtr;
#endif
and this is the errors it gives me:
error LNK2005: "class Products * nodePtr" (?nodePtr@@3PAVProducts@@A) already defined in List.obj
error LNK2005: "class Products * first" (?first@@3PAVProducts@@A) already defined in List.obj
error LNK1169: one or more multiply defined symbols found
Products* first;
andProducts* nodePtr;
asextern
in the header, and once inList.cpp
. – πάντα ῥεῖ