954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

error C2228: left of '.quickSort' must have class/struct/union

Hello, I was wondering how I could correct this. It is referring to the following line:

set.quickSort(prt1, 0, arraySize-1);


I tried to create an object and call the function this way but I am not sure how to correct this error.


My code is the following:

bool Sort::test()
{
	Sort set();
bool answer = false;

	//int arraySize;
	cout << "Enter the size of the array: ";
	//cin >> arraySize;
	cout << "50";
	arraySize = 50;
	cout << "Array being randomly populated with integers.";

	// pointers add/change values in the array indirectly
    int *prt1=new int[arraySize];
  

    // randomize the random number generator using current time
   srand ( (unsigned)time ( 0 ) );

    //insert numbers into array
    for (int i=0; i<arraySize; i++)
        *(prt1 + i)= 1 + rand() % 1000;
		//*(prt2 + i)= *(prt3 + i) =

    //print the numbers
    cout << "\n\nThe numbers before sorting are:\n";
    for (int i=0; i<arraySize; i++)
        cout << *(prt1 + i) << "\t";


    set.quickSort(prt1, 0, arraySize-1);

	 //print the sorted numbers
    cout << "\n\nThe numbers after sorting are: \n";
    for(int i=0; i<arraySize; i++)
    cout << *(prt1 + i) << "\t"; 

	// test
	if(*(prt1 + 1) < *(prt1 + 2))
	{
		answer = true;
	}
	else

return answer;
}
QuantNeeds
Junior Poster in Training
96 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

Get rid of the paranthesis around set--

bool Sort::test()
{
	Sort set;
bool answer = false;
Alex Edwards
Posting Shark
972 posts since Jun 2008
Reputation Points: 392
Solved Threads: 109
 

Get rid of the paranthesis around set--

bool Sort::test()
{
	Sort set;
bool answer = false;


thank you :-D

QuantNeeds
Junior Poster in Training
96 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You