okay... some say that using operator cast will allow me to use one function definition
Type: Posts; User: -EquinoX-
okay... some say that using operator cast will allow me to use one function definition
that's what my original question is, would it be possible just to use one function definition to cover both (String, int) and (int, String) in overloading?
here is my operator*
String operator*(int n, const String& str){
String r;
if (n > 0){
for (int i = 0; i < n; i++)
r = str + str;
}
else if (n < 0)
okay lets get back to my first topic, when I just use that one... I get:
error: invalid conversion from âintâ to âconst char*â
error: initializing argument 1 of âString::String(const char*)â...
I see that explains, also another question about overloading unary operator.. I have the following:
String String::operator-(){
String r('x', strlen(itsPtr) + 1);
int j = 0;
for(int i =...
May I know the reason why?
If say I want to overload the following:
String operator*(const String& str, int n);
and my test case is:
String ab = ab0 * 3;
Dae mention the term "subject", what is he actually referring to?
so putting a const in that function parameter will make the bug apparent because the compiler will fail?
so are you saying that by putting a const in the function parameter gives an indication that the print shouldn't change the subject?
Could you give me more details why making the second argument a const reference would make it work?
My instructor said that if the writer of the code below made full use a language feature in C++ from one of the following:
References
The const qualifier
NULL vs. 0
bool
The friend specifier...
basically what I want to do is the following:
example:
52 to result in
00110100
not
Operations are +, - and * and bit shifting.. I guess the bit shifting would be easy as it is just shifting elements/bits in the vector... my only problem right now is how to convert those very long...
I need to implement my own using a vector, and then store digits.... is there any implementation out there that does this?
what if I want to represent a huge number such as 2^100 to a two's complement, an int definitely can't handle this....
shifting array elements... basically
should it be something like:
obj operator<< (const obj& b1, const int b2)
when overloading a bit shift in c++, does it actually take one arguments or two?? how does the function looks like?
so it should take two arguments you mean?
how about this one:
type& operator~=();
I get this error:
:35: error: expected primary-expression before â)â token
and does it return a test& or a test? a reference or a value?
why when I try to compile this
test& operator~ (const test& b1, const test& b2);
I get:
error: âtest& Htest::operator~(const test&, const test&)â must take âvoidâ
and how do I fix undefined reference errors:
undefined reference to `Simulator<25, 25>::Simulator(Vehicle*)'
undefined reference to `Simulator<25, 25>::~Simulator()'
thanks