Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJonBMN

Posted 06 August 2012 - 01:35 PM

This topic is done.

#2JonBMN

Posted 06 August 2012 - 01:27 PM

I do have one more problem with a variation of this program...

program

#include "stdafx.h"
#include <iostream>
#include "DoubleCheeseburgers.h"
using namespace std;
int main()
{
DoubleCheeseburgers = 20;
EatAtJoes();
system("pause");
return 0;
}

header

#ifndef SHAREALIKE_H_INCLUDED
#define SHAREALIKE_H_INCLUDED
extern int DoubleCheeseburgers;
void EatAtJoes();
#endif // SHAREALIKE_H_INCLUDED

storage.cpp

#include "stdafx.h"
#include <iostream>
#include "DoubleCheeseburgers.h"
using namespace std;
int DoubleCheeseburgers;
void EatAtJoes()
{
cout << "How many cheeseburgers today?" <<endl;
cout << DoubleCheeseburgers << endl;
}

I get the same linker error LNK1169.. heres the error code..

1>------ Build started: Project: learn, Configuration: Debug Win32 ------
1>learn.obj : error LNK2005: _main already defined in DoubleCheeseburgers.obj
1>C:\Users\JonBecher\documents\visual studio 2012\Projects\learn\Debug\learn.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#1JonBMN

Posted 06 August 2012 - 01:26 PM

I do have one more program with a variation of this program...

program

#include "stdafx.h"
#include <iostream>
#include "DoubleCheeseburgers.h"
using namespace std;
int main()
{
DoubleCheeseburgers = 20;
EatAtJoes();
system("pause");
return 0;
}

header

#ifndef SHAREALIKE_H_INCLUDED
#define SHAREALIKE_H_INCLUDED
extern int DoubleCheeseburgers;
void EatAtJoes();
#endif // SHAREALIKE_H_INCLUDED

storage.cpp

#include "stdafx.h"
#include <iostream>
#include "DoubleCheeseburgers.h"
using namespace std;
int DoubleCheeseburgers;
void EatAtJoes()
{
cout << "How many cheeseburgers today?" <<endl;
cout << DoubleCheeseburgers << endl;
}

I get the same linker error LNK1169.. heres the error code..

1>------ Build started: Project: learn, Configuration: Debug Win32 ------
1>learn.obj : error LNK2005: _main already defined in DoubleCheeseburgers.obj
1>C:\Users\JonBecher\documents\visual studio 2012\Projects\learn\Debug\learn.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

PARTNERS