I am getting these errors Compiler Error C3867 (((( 'func': function call missing argument list; use '&func' to create a pointer to member ))))
nothing
#include <iostream>
using namespace std;
class Cuzmo
{
private:
int array[1000];
int n;
public:
Cuzmo ()
{
int array[] = { 95, 45, 48, 98, 485, 65, 54, 478, 1, 2325 };
int n = sizeof (array) / sizeof (array[0]);
}
void printArray (int* array, int n)
{
for (int i = 0; i < n; ++i)
cout << array[i] << endl;
}
void bubbleSort (int* array, int n)
{
bool swapped = true;
int j = 0;
int temp;
while (swapped)
{
swapped = false;
j++;
for (int i = 0; i < n - j; ++i)
{
if (array[i] > array[i + 1])
{
temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
swapped = true;
}
}
}
}
};
int main ()
{
Cuzmo sort;
cout << "Before Bubble Sort :" << Cuzmo::printArray << endl;
cout << Cuzmo::bubbleSort << endl;
cout << "After Bubble Sort :" << Cuzmo::printArray << endl;
return (0);
}
I am getting these errors Compiler Error C3867 (((( 'func': function call missing argument list; use '&func' to create a pointer to member ))))
This is not how you call a function f
with no arguments:
f;
This is how you do it:
f();
Furthermore, you're trying to send the return value of bubbleSort()
to cout
, but there is no such value as the function has void
return type.
In fact, the same is true of your printArray()
function: it already does the printing, and there is no result value to send to cout
.
Try:
cout << "Before Bubble Sort :";
Cuzmo::printArray();
cout << endl;
Cuzmo::bubbleSort();
cout << "After Bubble Sort :";
Cuzmo::printArray();
cout << endl;
The other problem is that you are declaring and initialising a local variable array
in your constructor; this variable has nothing to do with the member.
The same is true of your variable n
. You keep redeclaring new, local variables that shadow the member variables.
Maybe you simply forgot the parentheses after your function calls? Try Cuzmo::printArray()
and Cuzmo::bubbleSort()
. Also, you may want to use std::vector instead of a fixed-size int array (so that you loop over your actual entries rather than 10000 mostly uninitialised values) and look into std::swap.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.