Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
1.40/5 (2 votes)
See more:
C++
double Price() {
	double l, m, s;
	l = 3.50;
	m = 2.50;
	s = 1.50;
	return Price();
}

void Sprite(int& x) {
	string large, medium, small;
	string size;
	double a, b, c;
	a = Price(l);  <big>// im trying to get the value of l from int Price into a. </big>
	cout << "Large, Medium, or Small?" << endl;
	getline(cin, size);
	if ((size == "Large" || (size == "large")) { // ignore this part
		cout << "That will be" <<
	};
}
Posted
Updated 26-Aug-15 20:06pm
v4
Comments
Maciej Los 27-Aug-15 2:07am    
And the question is...

1 solution

That code looks like you guessed and hoped it might work without thinking about it: it won't.
Why not? Because as soon as you call Price, it immediately calls Price, which calls Price, which...until your application runs out of stack space and crashes.

Please, sit down, think about your task, and try to work out what you need to do instead of just guessing. It's a much more viable strategy in the long run.
 
Share this answer
 
Comments
Member 11938755 28-Aug-15 2:21am    
Yeah im not sure what I was doing with functions. I just started and up till now to learn ive been giving myself a task and trying to complete it. It was pretty much like you said, a guess. Ill have to do some reading. Thanks for the response.
OriginalGriff 28-Aug-15 2:25am    
You're welcome! :laugh:

It's not difficult, buy you need to get your own head round it - I can't really explain better than your teacher did, because I can't even see when your eyes start to glaze over... ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900