fatal error LNK1169: one or more multiply defined symbols found?

Write your question here. Hi, it is me again. I am getting this error and cannot figure out what I am doing wrong. It is in visual studios 2013 again BTW.

[#include "stdafx.h" // Precompiled header
#include "iostream" // Input and output stream
using namespace std; // Meaning you don't have to put std:: before cout <<;.
int squareIntegers(); // Function Prototype
double squareDouble();
float squareFloat();


int squareIntegers(int x) { //Function
int solution; //Declaring the variable solution, which is an integer data type.
solution = x * x; // Squaring x.
return solution; //Returns solution

}



double squareDouble(double d) {
double answer;
answer = d * d;
return answer;
}

float squareFloat(float x, float y) {
float answer1;
float answer2;
answer1 = x * x;
answer2 = y * y;
return 0;
}

int main() //Main Function
{
cout << squareIntegers(22) << endl;
cout << squareDouble(12) << endl;
cout << squareFloat(132, 150) << endl; //Function call and display with value 22 (so x = 22)
system("pause"); // Helps with displaying the output of a program.
return 0; // Returns a value.
}
code]
Put the code you need help with here.
[/code]
Last edited on
can you use code tags please?

you need to read this:
http://www.cplusplus.com/doc/tutorial/functions/

for example, you prototype:
int squareIntegers();

but you call it like this:
squareIntegers(22)

you also do not need prototype declarations if you're implementing them before you call them.
i.e. delete these:
1
2
3
4

int squareIntegers(); // Function Prototype
double squareDouble();
float squareFloat();
Last edited on
I'm trying to but it keeps displaying like that.
besides the functions issue there is also this:
1
2
3
4
5
6
7
float squareFloat(float x, float y) {
	float answer1;
	float answer2;
	answer1 = x * x;
	answer2 = y * y;
	return 0;
}

why are you doing calculations and then return zero?

edit:
you also do not need this either:
#include "stdafx.h"
Last edited on
I did it because I cannot return both answer1 and answer2 twice. What is the function issue?
please read my first post. basically these lines:
1
2
3
4
int squareIntegers(); // Function Prototype
double squareDouble();
float squareFloat();

are wrong, and not even needed.

I did it because I cannot return both answer1 and answer2 twice.

You need to read that link i pasted on functions.
Okay
So, I read it but and why are
[int squareIntegers(); // Function Prototype
double squareDouble();
float squareFloat();], wrong. They are function prototypes.

Also, I get an error saying to include "stdafx.h" if I don't include it.

Also, for squareIntegers(22), I used this in my last program, and it worked fine. I have no idea what else could be the issue.
Also, how do you use the tags. I click on <>, then this comes up: , but where in the brackets do I paste my code? I pasted in the brackets and it doesn't work. Is there a specific location in the brackets where I should paste my code?
They are function prototypes.

Yes they are, but they don't match your functions!
This prototype:
 
int squareIntegers();

Tells your compiler you're going to supply a method that takes NO parameters and returns an integer. However when you get to your code:
 
int squareIntegers(int x) 

You're telling the compiler about a different function. This one takes an integer and returns an integer.

This issue becomes apparent when you move your functions implementations below your main function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "iostream" // Input and output stream
using namespace std; // Meaning you don't have to put std:: before cout <<;.

int squareIntegers(); // Function Prototype
double squareDouble();
float squareFloat();

int main() //Main Function
{
	cout << squareIntegers(22) << endl;
	cout << squareDouble(12) << endl;
	cout << squareFloat(132, 150) << endl;	//Function call and display with value 22 (so x = 22)
	system("pause");	// Helps with displaying the output of a program.
	return 0;	// Returns a value.
}

int squareIntegers(int x) {	//Function
	int solution;	//Declaring the variable solution, which is an integer data type. 
	solution = x * x;	// Squaring x.
	return solution;	//Returns solution

}

double squareDouble(double d) {
	double answer;
	answer = d * d;
	return answer;
}

float squareFloat(float x, float y) {
	float answer1;
	float answer2;
	answer1 = x * x;
	answer2 = y * y;
	return 0;
}

errors:

(10): error C2660: 'squareIntegers' : function does not take 1 arguments
(11): error C2660: 'squareDouble' : function does not take 1 arguments
(12): error C2660: 'squareFloat' : function does not take 2 arguments

Because your prototypes should be:

1
2
3
4

int squareIntegers(int); // Function Prototype
double squareDouble(double);
float squareFloat(float, float);

Last edited on
Okay, thanks for that, but I still have this error: "fatal error LNK1169: one or more multiply defined symbols found."

Does this mean in my squareFloat function, I need to make a struct, return the struct name? Will that get rid of this error?
I don't don't get any errors when I compile your code.
Hmmmm.... Stange. I even copy and pasted the code you had and I am still getting the error:
"fatal error LNK1169: one or more multiply defined symbols found."
Also, I still have to add #include "stdafx.h" or else I will get an error saying I am missing that.
I'm using visual studios 2013.
I got it running!
But I have two problems.

1) It says I have to return something in the squareFloat function, but whatever I return (even 0), it will show in the output display box? What can I return that will make nothing display?

2) How do I create spaces between numbers? For example, instead of 1213, how would I make this 12 13?
Okay, I figured out the spacing part, but I still need help on the return part.
Can someone please help? This is all I need and I will be done.
what is the function meant to do? "squareFloat" implies to me that you are squaring a float? i.e. it takes in one float and returns a float.

Also, I still have to add #include "stdafx.h" or else I will get an error saying I am missing that.

what kind of project have you created?? You don't need this at all.
Last edited on
Topic archived. No new replies allowed.