473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

'=' function as left operand Errors?

I'm having problems finishing my program, it keeps giving me the error '=':function as left operand. And im not sure what that means. It is supposed to be a function to calculate basic car rental prices. This piece of the program is where it is telling me its wrong. Im not sure how to fix it though. Any help would be excellent.

Expand|Select|Wrap|Line Numbers
  1. switch(car_type) 
  2.     { 
  3.         case 1: 
  4.             cost=29.90;
  5.             extra=0.29;
  6.             total=total(cost,days_rented,km_traveled,extra); 
  7.         break; 
  8.         case 2: 
  9.             cost=39.95;
  10.             extra=0.39;
  11.             total=total(cost,days_rented,km_traveled,extra); 
  12.         break;
  13.         case 3: 
  14.             cost=49.95;
  15.             extra=0.49;
  16.             total=total(cost,days_rented,km_traveled,extra); 
  17.         break; 
  18.         case 4: 
  19.             cost=59.95;
  20.             extra=0.59;
  21.             total=total(cost,days_rented,km_traveled,extra); 
  22.         break; 
  23.     }
Mar 5 '10 #1
3 12340
In your switch cases , you are assigning the function return values in variable . this is actually function name ( total) . Which means that you are having the same name for function and your variable (total) . That is why it is throwing the error. Change your variable name or change your function name . It will work fine.
Mar 5 '10 #2
Thank You so much! That makes so much more sense!
Mar 5 '10 #3
jkmyoung
2,057 Expert 2GB
Agreed. You probably want to remove that line from each of the statements, and put after the switch
Expand|Select|Wrap|Line Numbers
  1.             return total(cost,days_rented,km_traveled,extra);  
  2.  
This assumes your current function is something like
double total (int car_type, int days_rented, int km_traveled)
and you have another function like:
double total(double cost,int days_rented,int km_traveled,double extra)


edit- ah well too late.
Mar 5 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
6
by: gustav04 | last post by:
hi all i have a question: what is the difference between a c-function and an c++ class method (both do exactly the same thing). lets say, i have a function called print2std() and a class...
25
by: Java Böy | last post by:
could some body help me what's happening here... thanks.. char sc = "\x31\xc0" /* xor %eax, %eax */ "\x50" /* push %eax */...
9
by: Netocrat | last post by:
Any comments on the correctness of the statements 1, 2a, 2b, 3 and 4 in the code below? If they are correct, then the definition of an object as well as that of an lvalue is broken in C99 by the...
12
by: Clifford Stern | last post by:
In a function that returns two values, how do you read them? Consider the following function: int addsub(int x,int y) {int a,b; a=x+y; b=x-y; return(a,b);} trying to read the results, for...
7
by: Eric Lilja | last post by:
>From a book, I know the following is true for the comparison operators: An overloaded operator that is a class member is only considered when the operator is used with a *left* operand that is an...
2
by: Bill Jackson | last post by:
For example, class A: def __init__(self,a): self.a = a def __eq__(self, other): return self.a == other.a class B: def __init__(self,b):
6
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a...
33
by: Pietro Cerutti | last post by:
Hi group, assume the following declarations: char *func_1(void); void func_2(char **); I am allowed to do: char *c = func_1();
6
by: Vijay | last post by:
Hello everybody, I am new to the C language can anybody tell me the diffrence between char nm and char *nm ?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.