Hi. I'm new to this whole stuff, and I'm trying to make my own class to solve a range of maths problems. The class, unruprisingly, is called numbers.
There are 3 files which are causing me problems: numbers.h, problem27.cpp, numbers.cpp. I'll include the sources below. My problem is the error message, when I try to execute problem27.cpp.
/home/bumcheekcity/Desktop/C++/euler/problem27/src/problem27.cpp:13: undefined reference to `numbers::numbers()'
Line 13, btw, is the line numbers num; in problem27.cpp. What am I doing wrong? I'm using "Problem Solving, Abstraction and Design in C++" by Friedman to help me learn, and programming on Ubuntu Linux, using KDevelop. Any assistance will be much appreciated.
numbers.h
problem27.cppCode://These lines are used to make sure that there are no problems with multiple definitions. #ifndef NUMBERS_H_ #define NUMBERS_H_ class numbers { public : //Constructors numbers(); numbers(float); //Obvious ones void decrement(); void increment(); bool is_int(); bool is_prime(); void set_value(float); float show_value(); private: float value; }; #endif
numbers.cppCode:#ifdef HAVE_CONFIG_H #include <config.h> #endif #include <iostream> #include <cstdlib> #include "numbers.h" using namespace std; int main(int argc, char *argv[]) { numbers num; cout << "is the value"; //num.increment(); cout << "is the new value"; return EXIT_SUCCESS; }
Code:#include <iostream> #include <maths> #include "numbers.h" //Here are the two constructors, one with, one without argument. numbers::numbers() { value = 0; } numbers::numbers(float initial_value) { value = initial_value; } //End constructors. void decrement() { value--; } void increment() { value++; } bool is_int() { } bool is_prime() { //Obvious } void set_value(float new_value) { value = new_value; } float show_value() { return value; }



LinkBack URL
About LinkBacks



