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 7837911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:54:30+00:00 2026-06-02T14:54:30+00:00

I have the file long_arithm.cpp: #ifndef LONG_ARITHM.CPP #define LONG_ARITHM.CPP #include <iostream> #include <list> namespace

  • 0

I have the file long_arithm.cpp:

#ifndef LONG_ARITHM.CPP
#define LONG_ARITHM.CPP

#include <iostream>
#include <list>

namespace long_arithm {

    typedef signed char schar;
    enum { error_char = 127 };

    class longint {
    public:
        longint() : minusSign(0), array() { }
        longint(int num) { fromInt(num); }
        longint(std::string str) { fromString(str); }
        longint(const longint& other) : minusSign(other.minusSign), array(other.array) { }

        void fromInt(int num);
        void fromString(std::string str);

    protected:
        schar digtochar(schar num);
        schar chartodig(schar ch);

        inline bool isDigit(schar ch) { /* code */ }
        inline bool isSpaceChar(schar ch) { /* code */ }

    private:
        bool minusSign;
        std::list<schar> array;
    };
};


void long_arithm::longint::fromInt(int num) {
    /* code */
}

void long_arithm::longint::fromString(std::string str) {
    /* code */

long_arithm::schar long_arithm::longint::digtochar(schar num) {
    /* code */
}

long_arithm::schar long_arithm::longint::chartodig(schar ch) {
    /* code */
}

#endif

Now I’m trying build it, but I have errors (1st and 2nd lines – Eclipce header):

Building target: long_arithmetics
Invoking: Cross G++ Linker
g++  -o "long_arithmetics"  ./long_arithm.o ./main.o   
./main.o: In function `long_arithm::longint::fromInt(int)':
/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:153: multiple definition of `long_arithm::longint::fromInt(int)'
./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:153: first defined here
./main.o: In function `long_arithm::longint::fromString(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:168: multiple definition of `long_arithm::longint::fromString(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:168: first defined here
./main.o: In function `long_arithm::longint::chartodig(signed char)':
/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:204: multiple definition of `long_arithm::longint::chartodig(signed char)'
./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:204: first defined here
./main.o: In function `long_arithm::longint::digtochar(signed char)':
/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:188: multiple definition of `long_arithm::longint::digtochar(signed char)'
./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:188: first defined here

(Note, the line links (like :188) are broken, because I threw out a lot of commented lines of code.)

Why I have that errors and what I should correct? As good as I understand,

void fromInt(int num);

and others are ‘pre-definitions’, and I don’t see any other definitions of that methods.

Thank you for help.

  • 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-02T14:54:32+00:00Added an answer on June 2, 2026 at 2:54 pm

    The functions that are defined outside of the class definition must either be moved to a source (.cpp) file or you must use the inline keyword at the front of them. Otherwise a copy of the function is placed into each source file that includes the header and marked as available to other modules, and the linker complains when there’s more than one.

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

Sidebar

Related Questions

I have the following header file: #ifndef DATABASE_H #define DATABASE_H #include <vector> #include <iostream>
I have long file with the following list: /drivers/isdn/hardware/eicon/message.c//add_b1() /drivers/media/video/saa7134/saa7134-dvb.c//dvb_init() /sound/pci/ac97/ac97_codec.c//snd_ac97_mixer_build() /drivers/s390/char/tape_34xx.c//tape_34xx_unit_check() (PROBLEM)/drivers/video/sis/init301.c//SiS_GetCRT2Data301() /drivers/scsi/sg.c//sg_ioctl()
I have a language file with a long list of strings for my view
i have a file containing list paths and other related information of all the
I have a file that I want to include in Python but the included
I have a text file with a long list of terms (approx 800) sorted
I have a file which has been tested and works as intended: #ifndef PROMOTE_H_INCLUDED
I have a long xml file the content of the file are below: <?xml
I have an XML file that is very long, but here is a shot
I have a text file that is pretty long. Any easy way to undo

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.