Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 ))))

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
161 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...