Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8955135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:28:46+00:00 2026-06-15T14:28:46+00:00

i am doing some example programs in VC++ 6.0 . For some simple and

  • 0

i am doing some example programs in VC++ 6.0 . For some simple and small programs i dont want to create separate project for each of the program . i have 2 files created in a single project and there is no .h file , so i have included .cpp file into another .cpp file .
If i compile its working but if i build the code its giving error . Following is the code :

file1.cpp :
-----------

#include <iostream>
#include "Calculate_Int.cpp"
using namespace std;

int main ()
{
    cout << "\n\nFirst file \n" ;

    int x= cal_integer();

    return 0;

}


Calculate_Int.cpp:
------------------

#include<iostream>
using std::cout;
using std::endl;

int cal_integer(){
    cout<< 1+2<<endl;
    cout<<1-5<<endl;
    cout<<1-2<<endl;

        return 0;
}

If i build this Project1.exe following is the error :

Linking…
Calculate_Int.obj : error LNK2005: “int __cdecl cal_integer(void)” (?cal_integer@@YAHXZ) already defined in file_1.obj
Debug/Project_1.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

Project_1.exe – 2 error(s), 0 warning(s)

Please let me know what is wrong .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:28:48+00:00Added an answer on June 15, 2026 at 2:28 pm

    Including a file is the same as copying the contents of that file in the point you are including it. This means that the contents of Calculate_Int.cpp are compiled twice in your project. And this is what the linker error is telling you: it does not know which version to choose.

    In order to compile main.cpp you just need to know the signature of the functions you are using there; this is, you just need a declaration, not a definition. So you can replace this line in main.cpp:

    #include "Calculate_Int.cpp"
    

    with this:

    int cal_integer();
    

    And your project will compile and link just fine. Anyway, the right way would be to create a file Calculate_Int.h with that line and include it anywhere you need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing some simple programs with opencv in python. I want to write
I have a program that returns a comma-separated string of numbers after doing some
I'm doing some small program for a beginners programming course and in my program
I have a long running program, my_prog that has some output that I want
For example, if I'm doing some form input validation and I'm using the following
Doing some jquery animation. I have certain divs set up with an attribute of
While doing some random experimentation with a factorial program in C, Python and Scheme.
I have a program for some scientific simulation stuff, and as such needs to
I'm doing some prototyping work in C, and I want to compare how long
I've got a small Java program that I'm developing for a project, which pulls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.