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

  • SEARCH
  • Home
  • 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 4041504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:53:19+00:00 2026-05-20T12:53:19+00:00

project1.cpp #include stdafx.h #include Bicycle.cpp using namespace std; int _tmain(int argc, _TCHAR* argv[]) {

  • 0

project1.cpp

#include "stdafx.h"
#include "Bicycle.cpp"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    bool runP = true;
    do {
    Bicycle object();
    char oType;
    cout << "Would you like a (B)icycle, or (A)nimal? E for Exit\n";
    cin >> oType;

    if (oType == 'B' || oType == 'b') {
        int seat, wheels;
        string brand;
        cout << "How many wheels does the bike have?\n";
        cin >> wheels;
        object().setWheels(wheels);
        cout << "How many seats does the bike have?\n";
        cin >> seat;
        object().setSeats(seat);
        cout << "What is the brand of the bike?\n";
        cin >> brand;
        object().setBrand(brand);
        object().toString();
    } else if (oType == 'A' || oType == 'a') {
    } else if (oType == 'e' || oType == 'E') {
        runP = false;
    }

    } while (runP == true);
    return 0;
}

Bicycle.h

#include <string>

class Bicycle {

private:
    int wheels;
    int seats;
    std::string brand;
public:
    Bicycle();
    Bicycle(int w, int s, std::string b);
    int getWheels();
    int getSeats();
    std::string getBrand();
    void setWheels(int w);
    void setSeats(int s);
    void setBrand(std::string b);
    void toString();

};

Bicycle.cpp

#include "stdafx.h"
#include "Bicycle.h"
#include <string>


    Bicycle::Bicycle() {
    }
    Bicycle::Bicycle(int w, int s, std::string b) {
    }
    int Bicycle::getWheels() {
        return wheels;
    }
    int Bicycle::getSeats() {
        return seats;
    }
    std::string Bicycle::getBrand() {
        return brand;
    }
    void Bicycle::setWheels(int w) {
        wheels = w;
    }
    void Bicycle::setSeats(int s) {
        seats = s;
    }
    void Bicycle::setBrand(std::string b) {
        brand = b;
    }
    void Bicycle::toString(){
        std::cout << "Bike object has: Brand: " << getBrand() << ", wheels: " << getWheels() << ", seats: " << getSeats() << "\n";
    }

stdafx.h

    #pragma once

#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>

Error:

1>------ Build started: Project: project1, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  Bicycle.cpp
1>  Generating Code...
1>  Compiling...
1>  project1.cpp
1>  Generating Code...
1>  Skipping... (no relevant changes detected)
1>  Window.cpp
1>  Animal.cpp
1>project1.obj : error LNK2005: "public: __thiscall Bicycle::Bicycle(void)" (??0Bicycle@@QAE@XZ) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: __thiscall Bicycle::Bicycle(int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Bicycle@@QAE@HHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: int __thiscall Bicycle::getWheels(void)" (?getWheels@Bicycle@@QAEHXZ) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: int __thiscall Bicycle::getSeats(void)" (?getSeats@Bicycle@@QAEHXZ) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Bicycle::getBrand(void)" (?getBrand@Bicycle@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: void __thiscall Bicycle::setWheels(int)" (?setWheels@Bicycle@@QAEXH@Z) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: void __thiscall Bicycle::setSeats(int)" (?setSeats@Bicycle@@QAEXH@Z) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: void __thiscall Bicycle::setBrand(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setBrand@Bicycle@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in Bicycle.obj
1>project1.obj : error LNK2005: "public: void __thiscall Bicycle::toString(void)" (?toString@Bicycle@@QAEXXZ) already defined in Bicycle.obj
1>project1.obj : error LNK2019: unresolved external symbol "class Bicycle __cdecl object(void)" (?object@@YA?AVBicycle@@XZ) referenced in function _wmain
1>C:\Users\Hash\Documents\Visual Studio 2010\Projects\project1\Debug\project1.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 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-05-20T12:53:20+00:00Added an answer on May 20, 2026 at 12:53 pm

    Pretty sure instead of

    #include "Bicycle.cpp"
    

    you want

    #include "Bicycle.h"
    

    With the first, everything in Bicycle.cpp gets copy-pasted into project1.cpp and you get duplicate definitions with one set of bicycle functions defined when project1.cpp is compiled, and the other when Bicycle.cpp is compiled.

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

Sidebar

Related Questions

#include stdafx.h #include <iomanip> #include <iostream> #include <fstream> using namespace std; void FillArray (int
include stdafx.h #include <iostream> using namespace std; class Foo{ public: void func() { cout<<Hello!!<<endl;
//head.h// extern int sum(int,int); //head.cpp// #include head.h #include stdafx.h int sum(int x, int y)
I have a code like this below in /root_project/main.cpp : #include theoraplayer/TheoraVideoClip.h unsigned int
// diskbin.cpp : main project file. #include stdafx.h #include <windows.h> #include <iostream> #include <fstream>
Below is a simple C++/CLI example. // TestCLR.cpp : main project file. #include stdafx.h
Hey guys. Check out this piece of sample code. #include stdafx.h #include<conio.h> #include<string.h> class
The following for creating a Global Object is resulting in compilation errors. #include stdafx.h
I decided to include a library (more specifically yaml-cpp ) in my project. Since
header.h #include <iostream> #include <vector> class CombatLine{ std::stringstream Line; std::vector<std::string> TokenLine; void SetLine(std::string s){

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.