how to fix function call missing argument list in this case ?

I'm trying to learn cpp and inheritance, and I trying this example to display some data saved in vectors

but I got this error
C:\Users\P\Documents\looptest\main.cpp:74: error: C3867: 'FeatureProd::getLS': function call missing argument list; use '&FeatureProd::getLS' to create a pointer to member

code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <string>
#include <vector>
using namespace std;

class myProd{
private:
    int nProd;
    string sProd;
public:
    myProd(){}
    myProd(string s, int n):sProd(s), nProd(n){}

    ~myProd(){}
    int getN(){
        return this->nProd;
    }

    string getS(){
        return this->sProd;
    }
    bool equalProd(myProd p){
        if(this->nProd == p.getN() && this->sProd == p.getS())
            return true;
        else
            return false;
    }
    void display(){
        cout << this->sProd << this->nProd << endl;
    }
};

class FeatureProd : public myProd{
private:
    myProd prod;
    int length2skip;

public:
    FeatureProd(string s, int n, int ls):prod(s, n), length2skip(ls){}

    ~FeatureProd(){}

    int FeatureProd::getLS(){
        return this->length2skip;
    }
};

int main()
{
    cout << "Hello World!" << endl;
    vector<myProd> vectProds =
    {
        {"S",1}, {"A",1}, {"A",2}, {"A",3}, {"A",4}, {"A",5}, {"A",6},
        {"S",2}, {"S",3}, {"B",1}, {"B",2}, {"B",3}, {"B",4}, {"B",5},
        {"B",6}, {"S",4}, {"S",5}, {"S",6}, {"C",1}, {"C",2}, {"C",3},
        {"C",4}, {"C",5}, {"C",6}, {"S",7}, {"S",8}, {"S",9}, {"S",10},
        {"D",1}, {"D",2}, {"D",3}, {"D",4}, {"D",5}, {"D",6}, {"S",11},
        {"E",1}, {"E",2}, {"E",3}, {"E",4}, {"E",5}, {"E",6}, {"S",12}
    };
    vector<vector<FeatureProd>> kws =
    {
        { {"A",2,6}, {"A",4,6}, {"A",6,6}},
        { {"B",2,6}, {"B",4,6}, {"B",6,6}},
        { {"C",2,6}, {"C",4,6}, {"C",6,6}},
        { {"D",2,6}, {"D",4,6}, {"D",6,6}},
        { {"E",2,6}, {"E",4,6}, {"E",6,6}}
    };
    size_t total_columns = kws[0].size();
        for (auto& s : vectProds){
            for (int col=0; col<total_columns; ++col){
                cout << s.getS() <<s.getN() << endl;
                for(auto& row : kws){
                        cout << "=> " << row[col].getS()<<row[col].getN()<< " ";
                        cout << row[col].getLS << endl;
                }
                cout << endl;
            }
        }

    return 0;
}
Last edited on
getLS appears to be a function not a variable, perhaps you need parentheses and any required parameters?

@jlb
getLS appears to be a function not a variable, perhaps you need parentheses and any required parameters?


that's right, but why when I try to display kws content I do not get the right one?

1
2
3
4
5
6
7
Hello World!
S1
=> 128 6
=> -1504852704 6
=> -1504839680 6
=> 0 6
=> -1504902400 6
Last edited on
that's right, but why when I try to display kws content I do not get the right one?


I fixed that by adding these functions into

can some explain that ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class FeatureProd : public myProd{
private:
    myProd prod;
    int length2skip;

public:
    FeatureProd(string s, int n, int ls):prod(s, n), length2skip(ls){}

    ~FeatureProd(){}

    int FeatureProd::getLS(){
        return this->length2skip;
    }
    int getN(){
        return prod.getN();
    }

    string getS(){
        return prod.getS();
    }
};
Topic archived. No new replies allowed.