LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2016, 12:40 AM   #1
codex96
LQ Newbie
 
Registered: Feb 2016
Posts: 5

Rep: Reputation: Disabled
I have a error saying "undefined reference to...." in operator overload c++ code


I was trying to build a overload operator+ code for a feet and inches program and i seem to have finished and i get errors saying "Undefined reference FeetInches(unsigned int = 0, int = 0)". and it odly doesnt give me a line to find the errors at. ill put a link to my code below that way the formatting doesnt look weird.

http://paste.ofcode.org/bVmwLrZw5vWd7zc86qFJ4W
 
Old 03-18-2016, 12:49 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You forgot to implement the constructor. Or it can be inline:
Code:
   FeetInches (unsigned int pf= 0, int pi= 0) { feet= pf; inches= pi; }
 
Old 03-18-2016, 01:05 AM   #3
codex96
LQ Newbie
 
Registered: Feb 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
You forgot to implement the constructor. Or it can be inline:
Code:
   FeetInches (unsigned int pf= 0, int pi= 0) { feet= pf; inches= pi; }
im new to friens, constructors, overload can i possible ask you to show me the implementation part?
 
Old 03-18-2016, 02:05 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,863
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
The part between '{' and '}'. The separate implementation would be sg. like this:
Code:
FeetInches::FeetInches(unsigned int pf, int pi)
{
    feet= pf;
    inches= pi;
}
Edit: You seems to have forgotten these complier options: -W -Wall -Wextra -Werror

Last edited by NevemTeve; 03-18-2016 at 04:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"undefined reference" error when trying to use GTL in a simple C++ application m4h Programming 6 03-29-2012 12:45 PM
Error "Undefined reference" while compiling a c program in linux acharyaa Linux - General 4 07-25-2011 11:16 PM
Error when "make" the source of CosmoMC: undefined reference to `dpotrf_' limh Linux - Software 1 09-30-2009 02:27 PM
"undefined reference"linker error for static field w/ C++ astorm Programming 5 08-27-2008 03:00 AM
Error: Make on kismet-2005-08-R1 "undefined reference" zeevolking Linux - Software 1 12-23-2005 08:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration