Conflicting Errors in Visual Studio (C++)

I have a function "PrintHeader" for my project, defined in io.cpp. Even though io.h is included in my main file, I get the error

error C3861: 'PrintHeader': identifier not found.

When I copy the function for PrintHeader into my main file, I get the errors

error LNK2005: 'void _cdeci PrintHeader(void)" (?PrintHeader@@YAXXZ) already defined in io.obj.  

and

error LNK1169: one or more multiply defined symbols found.

I can understand the second error set, since I do have it defined twice, but I don't understand why it doesn't work when I just remove the duplicate definition. Any help is greatly appreciated.

Main file

#include "stdio.h"
#include <iostream>
#include "io.h"

void PrintHeader()
{
    cout << endl;
    cout << "Month\tPrincipal\t Interest\t  Balance" << endl;
    cout << "-----\t---------\t---------\t---------" << endl;
}
int main()
{
    cout << "Hello World\n";
    PrintHeader();
    getchar();
    return 0;
}  

io.cpp

#include <iostream>
#include <iomanip>
#include "io.h"

void PrintHeader (void)
{
    cout << endl;
    cout << "Month\tPrincipal\t Interest\t  Balance" << endl;
    cout << "-----\t---------\t---------\t---------" << endl;
}

io.h

#ifndef __IO_H__
#define __IO_H__

#include <string>
using namespace std;

void PrintHeader (void);

#endif

Answers


You are most likely including the wrong file in main.cpp. You can make sure it is the right file by right clicking on the include "io.h" and choosing open file.


Need Your Help

Bubble sort a linklist template

visual-c++ data-structures bubble-sort

I am trying to sort a linked list. I am having problems with const. It wont let me assign to a variable that is const which is what it suppose to do. However, I dont' know how to work around this?

Troubles Overwritting Wordpress Url Rewrites

php wordpress .htaccess rewrite permalinks

so essentially right now I have a plugin enabled to allow me to use php in my pages. I've setup a page and set the permalink as the homepage. Doing this I'm able to make requests like

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.