I am receiving a strange error, one I have never seen before.
error LNK2019: unresolved external symbol "public: __thiscall Complex::~Complex(void)" (??1Complex@@QAE@XZ) referenced in function _main
I also receive a fatal error:
fatal error LNK1120: 1 unresolved externals
If I do: #include "Complex.h" that takes care of the top error, however I still receive the fatal error.
I'm not sure what could be causing these. Any ideas?? -
-
#include<iostream>
-
using namespace std;
-
//#include "Complex.h"
-
class Complex
-
{
-
public:
-
Complex(double =0.0, double= 0.0);
-
~Complex();
-
Complex operator+(Complex &);
-
Complex operator*(Complex &);
-
void print ();
-
private:
-
double real;
-
double imaginary;
-
};
-
Complex::Complex(double r_port, double i_port):real(r_port),imaginary(i_port)
-
{
-
-
}
-
Complex Complex::operator+(Complex &operand2)
-
{
-
return (Complex(real+operand2.real,imaginary+operand2.imaginary));
-
}
-
Complex Complex::operator*(Complex &operand2)
-
{
-
return (Complex(real*operand2.real,imaginary*operand2.imaginary));
-
}
-
void Complex::print()
-
{
-
cout<<'('<<real<<','<<imaginary<<')';
-
}
-
void main ()
-
{
-
double real1,imag1,real2,imag2;
-
cout<<"Enter your first real number: "<<endl;
-
cin>>real1;
-
cout<<"Enter your first imaginary number: "<<endl;
-
cin>>imag1;
-
cout<<"Enter your second real number: "<<endl;
-
cin>>real2;
-
cout<<"Enter your second imaginary number: "<<endl;
-
cin>>imag2;
-
// Complex x;
-
Complex x(real1,imag1);
-
Complex y(real2,imag2);
-
cout<<"x: ";
-
x.print();
-
cout<<endl<<"y: ";
-
y.print();
-
// cout<<endl<<"z: ";
-
// z.print();
-
}
-
-
Thanks,
J
10 1519
As far as I can see you forgot to define your ~Complex() dtor but you did declare
it; you must define it then.
kind regards,
Jos
As far as I can see you forgot to define your ~Complex() dtor but you did declare
it; you must define it then.
kind regards,
Jos
Awesome Jos. I am looking at my past programs and in the book, and nowhere did I (or the author) define their destructor. That did it though.
Thanks,
J
Found the problem....program is working.
Thanks to those who took a look and offered advice.
J
Awesome Jos. I am looking at my past programs and in the book, and nowhere did I (or the author) define their destructor. That did it though.
Thanks,
J
You didn't define it BUT you did declare it. If you don't declare it, one will be created for you automatically, but since you declared one, you must define it also.
You didn't define it BUT you did declare it. If you don't declare it, one will be created for you automatically, but since you declared one, you must define it also.
Cool. Like I said, I've never had to define one in any of the other programs I've wiritten.
Thanks for taking a look Darryl.
J
The overloading problem has been solved. I missed in the assignment the part around using set and get functions. The set function is where I would actually enter the numbers from the user? And the get function would.....send those values to the print function??
I get confused about the set and get functions.
J
Cool. Like I said, I've never had to define one in any of the other programs I've wiritten.
Thanks for taking a look Darryl.
J
I'll bet you did...You can't show me 1 piece of code that declares a destructor and didn't define it also and still compiles. Maybe you defined it inline and didn't realize it like: -
class foo
-
{
-
public:
-
// ~foo(); - not defined
-
~foo(){} // ok
-
};
-
The braces there defines it.
hi dear
u forget to defined ur ~complex(); detroyed function/
You're right Daryl, that is how I defined the destructor.
My next question is, I need to implement set and get functions. I missed that little line in the problem. Does the set function just initialize the 2 sets to 0,0 and the get function take in the info of the 2 sets? The set and get functions still confuse me for some reason.
J
Problem solved.
Thanks,
J
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim Milstead |
last post by:
(CODE AT END OF POST)
I have got some code for finding memory leaks that works well with:
new()
and needs to be extended to work with
new
|
by: Pmb |
last post by:
I've been working on creating a Complex class for my own learning purpose
(learn through doing etc.). I'm once again puzzled about something. I can't
figure out how to overload the assignment...
|
by: James Angi |
last post by:
I have a question on operator overloading that I can't find an answer to in
several guides (even google has failed me).
I'm currently making my way through several C++ guides, trying to become...
|
by: Jerry Fleming |
last post by:
As I am newbie to C++, I am confused by the overloading issues. Everyone
says that the four operators can only be overloaded with class member
functions instead of global (friend) functions: (), ,...
|
by: y-man |
last post by:
Hi,
I am trying to get an overloaded operator to work inside the class it
works on. The situation is something like this:
main.cc:
#include "object.hh"
#include "somefile.hh"
object obj,...
|
by: jakester |
last post by:
I am using Visual C++ 2007 to build the code below. I keep getting
linkage error. Could someone please tell me what I am doing wrong? The
code works until I start using namespace for my objects.
...
|
by: EM.Bateman |
last post by:
Working on Visual Studio .Net I've implemented a class:
#ifndef CONTRIBUTOR_H
#define CONTRIBUTOR_H
enum Gender {male=1, female, unk};
#include <iostream>
#include <iomanip>
#include...
|
by: ashu |
last post by:
i have studied this example of overloading operator, but i don`t
know exactly what happened in code .kindly explain me:
#include <iostream>
using namespace std;
const int SIZE = 3;
class...
|
by: clicwar |
last post by:
A simple program with operator overloading and copy constructor:
#include <iostream>
#include <string>
using namespace std;
class Vector {
private:
float x,y;
public:
Vector(float u, float...
|
by: =?Utf-8?B?VkIgRGV2ZWxvcGVy?= |
last post by:
Overloading of the unary ++ operator in vb.net is not working. It show error:
Operator declaration must be one of: +, -, *, \, /, ^, &, Like, Mod, And,
Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |