Cannot Be Used As A Function Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
C++ Cannot Be Used As Function
Stack Overflow the company Business Learn more about hiring developers or posting ads with error expression cannot be used as a function c++ us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a
Cannot Be Used As A Function Mathematica
community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error: expression cannot be used as a function. How to remove this? up vote -1 cannot be used as a function arduino down vote favorite I am using this structure struct box { int h,w,d; }; int compare (const void *a, const void * b) { return ((*(box *)b).d * (*(box *)b).w) – ((*(box *)a).d * (*(box *)a).w); // error is showing in this line } box rot[3*n]; qsort (rot, n, sizeof(rot[0]), compare); and I am trying qsort but showing error expression cannot be used as a function in c++ compare qsort time cannot be used as a function share|improve this question asked Jan 8 '15 at 5:44 Parshant garg 1 1 That character – in the middle of the long line is not a minus sign, but an n-dash. Once that is fixed, your code compiles for me –Igor Tandetnik Jan 8 '15 at 5:47 2 You'd probably have a much easier time figuring out your error if you wrote readable code. Condensing everything down to one statement buys you nothing. –Benjamin Lindley Jan 8 '15 at 5:47 @Igor Tandetnik Thanks it is also worked for me, but how you detect that? –Parshant garg Jan 8 '15 at 5:55 1 how you detect that? The compiler told me. –Igor Tandetnik Jan 8 '15 at 6:11 Just use std::sort. It's a lot faster. –MSalters Jan 8 '15 at 7:50 | show 2 more comments 1 Answer 1 active oldest votes up vote 0 down vote You have a problem with the minus operator in the return line which should be - instead of – another problem when defining the array rot which should contain elements of type struct box instead of box as there is NO typedef in the structure block So you are in front of two possibilities to make
here for a quick overview of the site Help Center Detailed answers to any
Expression Cannot Be Used As A Function Arduino
questions you might have Meta Discuss the workings and policies of variable cannot be used as a function this site About Us Learn more about Stack Overflow the company Business Learn more about hiring
Arduino Function
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is http://stackoverflow.com/questions/27833664/error-expression-cannot-be-used-as-a-function-how-to-remove-this a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “cannot be used as a function” error up vote -2 down vote favorite Please have a look at the following code #include New Topic/Question Reply 2 Replies - 17603 Views - Last Post: 03 March 2009 - 07:25 PM Rate Topic: #1 thwhisler New D.I.C Head Reputation: 1 http://www.dreamincode.net/forums/topic/90425-error-cannot-be-used-a-function/ Posts: 11 Joined: 20-February 09 error: cannot be used a function Posted 03 March 2009 - 06:54 PM I am writing a program that will calculate the determinates of 2 by http://cboard.cprogramming.com/cplusplus-programming/79675-compile-problem-sort-cannot-used-function.html 2 or 3 by 3 matrixes. This is what i currently have: #include Programming Boards C++ Programming Compile problem: sort() cannot be used as a function!? Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Compile problem: sort() cannot be used as a function!? Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 06-01-2006 #1 ac251404 View Profile View Forum Posts Registered User Join Date May 2006 Posts 89 Compile problem: sort() cannot be used as a function!? Hi, I am doing a project comparing run times of STL sorts to sorts i have written. I am having a really weird compiler error that looks like this: Code: main.cc: In function 'int main(int, char**)': main.cc:56: error: 'sort' cannot be used as a function Here is some of the code from my main: Code: switch(sort){ case 'q': if(stl) sort(my_vect.begin(), my_vect.end()); else quick_sort(my_vect); break; case 'm': if(stl) stable_sort(my_vect.begin(), my_vect.end()); else merge_sort(my_vect); break; ... when i comment out the line that calls sort() everything works fine... even stable_sort which is from the same library and uses the same parameters. Also i have another small program just one file that calls sort() and it works there fine. This is completely insane and i cannot figure it out and any hints would be great. thanks 06-01-2006 #2 hk_mp5kpdw View Profile View Forum Posts Registered User Join Date Jan 2002 Location Northern Virginia/Washington DC Metropolitan Area Posts 3,817 Code: switch(sort){ case 'q': if(stl) sort(my_vect.begin(), my_vect.end()); Possible confusion due to variable name being similar to function name? Try changing the name of the variable in your code to something else. "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods." -Christopher Hitchens 06-01-2006 #3 laserlight View Profile View Forum Posts Visit Homepage C++ Witch Join Date Oct 2003 Location Singapore Posts 25,444 Code: switch(sort){ Apparently you have a variable named sort. I suggest that you dont have a using namespace std directive or a using std::sort directive, but instead use the fully qualified names. Code: switch(sort){ case 'q': if(stl) std::s