Type '_or' does not provide a call operator.

I am playing around with ODD and making a truth table generator.
The error / symptom I am receiving is when I am trying to compose fucntions with return types.

e.g.

1
2
3
4
5
6
7
8
9
 bool p =false;
    bool q =false;
    
    _or test(p,q);

    bool invar;
    
  invar = test.print();
    test(invar, true);


I would like to take
the output of invar (false in this case.)
and use it as input to the next call of the object.

but my compiler is complaining

Type '_or' does not provide a call operator.

due to my lack of knowledge and just learning about OOD I thought It was my
copy constructor or assignment (self) operator.

can someone take a look at what I might be doing wrong here?

Thanks in advance!



Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include "logic.h"
#include "_and.h" 
#include "_or.h"

int main(int argc, const char * argv[]) {

    
    bool p =false;
    bool q =false;
    
    _or test(p,q);

    bool invar;
    
  invar = test.print();
    test(invar, true);
    
    
    
    return 0;
};

logic.h
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
#ifndef __truth__logic__
#define __truth__logic__

#include <string>
using std::string;


class logic
{
public:
    /** Default constructor */
    logic();
    

    logic(bool lhs, bool rhs);
    virtual ~logic();
    /** Copy constructor
     *  \param other Object to copy from
     */
    logic(const logic& other);
    /** Assignment operator
     *  \param other Object to assign from
     *  \return A reference to this
     */
    logic& operator=(const logic& other);
    
    
    void setLhs(bool arg_lhs);
    void setRhs(bool arg_rhs);
    void setLhsRhs(bool arg_rhs, bool arg_lhs);
    bool getLhs() const;
    bool getRhs() const;
    
    virtual bool print() = 0;
    
    
    
    
protected:
    bool lhs;
    bool rhs;
   
};

logic.cpp
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
#include "logic.h"



logic::logic():lhs(true), rhs(true)
{


}

logic::logic(bool arg_rhs, bool arg_lhs):lhs(arg_lhs),rhs(arg_rhs){
    
    
    
}



logic::~logic()
{
    //dtor
}

logic::logic(const logic& other)
{
    //copy ctor
}


logic& logic::operator=(const logic &other){
    
    lhs = other.lhs;
    rhs = other.rhs;
    
    return *this;
    
    
}
/// Setters ///
void logic::setLhs(bool arg_lhs)
{
    
    lhs = arg_lhs;
    
    
}
void logic::setRhs(bool arg_rhs)
{
    
    rhs = arg_rhs;
    
}

void logic::setLhsRhs(bool arg_rhs, bool arg_lhs)
{
    
    rhs = arg_rhs;
    lhs = arg_lhs;
    
}

// getters //

bool logic::getLhs() const{
    
    return lhs;
    
}

bool logic::getRhs() const{
    
    return rhs;
    
}

_and.h
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

#ifndef __truth___and__
#define __truth___and__

#include <stdio.h>
#include <iostream>
#include "logic.h" 

using std::cout;
using std::boolalpha;


class _and : public logic {

    
public:
    
    
    _and();
    _and(bool arg_rhs, bool arg_lhs);
     bool print();
    

};
#endif /* defined(__truth___and__) */

-and.cpp
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

/**
 
 p | q | p&&q
 T | T | T
 T | F | F
 F | T | F
 F | F | F
 
 **/

#include "_and.h"



_and::_and()
{
    
    
}

_and::_and(bool arg_rhs, bool arg_lhs){
    
    lhs = arg_lhs;
    rhs = arg_rhs; 
    
    
}

 bool  _and::print(){

     bool r_value = false;
     r_value = (lhs && rhs);
     cout << boolalpha << r_value;
     return r_value;
     
     
    }

_or.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using std::cout;
using std::endl;
using std::boolalpha;


class _or : public logic

{
    _or(const _or& other);
    _or& operator=(const _or &other);
    
public:
    
    
     _or();
    _or(bool arg_rhs, bool arg_lhs);
    
    bool print();

_or.cpp
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

#include "_or.h"

/**
 p | q | p||q
 T | T | T
 T | F | T
 F | T | T
 F | F | F
 **/

_or::_or()
{
    
    
}


_or::_or(bool arg_rhs, bool arg_lhs){
    
    lhs = arg_lhs;
    rhs = arg_rhs;
    

}

_or::_or(const _or & other)
{
    lhs = other.lhs;
    rhs = other.rhs;
}

_or& _or::operator=(const _or &other){
    
    if (this == &other) {
        return *this;
    }
    
    
    lhs = other.lhs;
    rhs = other.rhs;
    
    return *this;
    
    
}

bool _or::print(){
    
    
    bool r_value = false;
    r_value = (lhs || rhs);
    cout << boolalpha << r_value;
    return r_value;
    
    
}; 
What do you expect line 17 to do in main?
good question. lol.

just take the input silently. Allowing me to call it later with print() or when I overload <<
I guess I would just need an constructor?
If you want to set the values in the class using your existing interface, it would be:

test.setLhsRhs(invar, true);

or:

test = _or(invar, true);
Topic archived. No new replies allowed.