![]() |
|
#1
|
|||
|
|||
help with a quicksort programI got some errors with my quicksort program. It is supposed to sort a vector and also count the number of swaps done. any help would be appreciate.
thank you my header file CPP / C++ / C Code:
my bub1 cpp file CPP / C++ / C Code:
and here is my bub file CPP / C++ / C Code:
here are the errors i get c:\\bub1.h(16) : error C2061: syntax error : identifier 'T' c:\\bub1.cpp(12) : error C2511: 'quicksort::quicksort' : overloaded member function 'void (void)' not found in 'quicksort' c:\\bub1.h(12) : see declaration of 'quicksort' c:\\bub1.cpp(56) : error C2244: 'quicksort::qsort' : unable to resolve function overload c:\\bub1.cpp(57) : error C2199: syntax error : found 'quicksort (' at global scope (was a declaration intended?) c:\\bub1.cpp(5 Error executing cl.exe. bub1.obj - 5 error(s), 0 warning(s) |
|
#2
|
||||
|
||||
Re: help with a quicksort programQuote:
You have defined your Constructor to take an unsigned int parameter in your class definition, but then only implemented the default constructor in the .cpp. You must implement the other one too, so the linker will be able to resolve the links Define the default constructor as well in the header while you are at it. Otherwise, you might leave the impression you are trying to hide the default constructor for the class from the users (although it is public by default, it might not be so obvious). Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
Re: help with a quicksort programim not getting what u mean?
|
|
#4
|
|||
|
|||
Re: help with a quicksort programi am completely lost in trying to fix this anymore suggestions?
|
|
#5
|
||||
|
||||
Re: help with a quicksort programDeclare the default constructor in the header file....(this is what Lucian meant)
CPP / C++ / C Code:
Then in your header file, you didnt define T. So, declare like this: CPP / C++ / C Code:
And in you main function, you didnt pass any arguments to the qsort function. So, change that like this: CPP / C++ / C Code:
Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#6
|
|||
|
|||
Re: help with a quicksort programa.qsort(data, first, last); //sort data
how do you go about declaring these identifiers? i get a error asking to declare them? |
|
#7
|
||||
|
||||
Re: help with a quicksort programI went through your code "in detail" many things were wrong.
First, where is the swap function? And, try to implement the quicksort function using int only, and then we'll switch to templates. According to your code, we cant pass the values in main. So, lets create an overloaded quick_sort function which takes no arguments, in the class: CPP / C++ / C Code:
And remove this unnecessary code in your bub.cpp(shouldn't it be qui.cpp?? CPP / C++ / C Code:
Another thing. You have used many headers in your files, which are unnecessary. And dont include headers in the cpp files again. It is already included in your header file. If you get the program correct, then as you posted earlier, use templates. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#8
|
|||
|
|||
Re: help with a quicksort programoye i am so lost on this one
|
|
#9
|
|||
|
|||
Re: help with a quicksort programreally need some help i cant get it to work at all it keeps telling me to declare data and it is due tonight any help would be appriciated
|
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating a file in [c] | i hate c | C Programming Language | 15 | 21-Nov-2005 12:52 |
| Type casts ? | kai85 | CPP / C++ Forum | 12 | 23-Jun-2005 12:04 |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 20:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The