0

Just wondering which of these functions would be faster (or if they would be the same):

class MyClass
{
    private:
    bool MyVar;
    public:
    MyClass &Function1(bool MyVar);
    MyClass &Function2(bool MyVar);
    MyClass &Function3(bool var);
};
MyClass &MyClass::Function1(bool MyVar)
{
    this->MyVar=MyVar;
    cout<<MyVar;
    return *this;
}
MyClass &MyClass::Function2(bool MyVar)
{
    this->MyVar=MyVar;
    cout<<this->MyVar;
    return *this;
}
MyClass &MyClass::Function3(bool var)
{
    MyVar=var;
    cout<<MyVar;
    return *this;
}
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Labdabeta
0

Your question is: does prefixing this to member access have a performance cost? The answer is no, it should not.

Edited by Narue: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.