[Cg1] Re: CPP Header files and local instances of classes

Fajar Setyo Nugroho s8fanugr at stud.uni-saarland.de
Thu Nov 1 15:09:26 CET 2018


Hi Julian,

I don't understand the technical term and my c++ is super rusty, but  
when I check this link here:  
https://www.learncpp.com/cpp-tutorial/9-2a-overloading-operators-using-normal-functions/ I could have some progress with the  
assignment.

Regards,
Fajar Setyo Nugroho


Quoting Julian Klein <s9jiklei at stud.uni-saarland.de>:

> Dear everybody,
>
> I am pretty confused about part of the homework:
>
> Let's take Vector.h for example.
>
> We are supposed to implement Vector.
>
> If we look at the header file, we see two types of method stubs (how  
> do you call that again properly?): The ones inside the scope of the  
> class Vector and the ones OUTSIDE of that scope.
>
> What's the difference between those?
>
> Also, the operators: Let's take a look at operator+(const Vector& b)  
> const, which is binary.
>
> But it has only one argument. When trying to access the variables of  
> the current class (to use the binary operator when only one argument  
> is passed in the method), I have to create a new local instance of  
> the class inside the implementation of the operator. Can that be  
> right? I think this is super weird, because I am returning a new  
> instance of the class! Should I do this differently or is this not a  
> problem?
>
>
> Best,
>
> j
>
> _______________________________________________
> Cg1 mailing list
> Cg1 at cg.uni-saarland.de
> http://mail.cg.uni-saarland.de/mailman/listinfo/cg1





More information about the Cg1 mailing list