|
From: <or...@vp...> - 2003-05-03 22:17:19
|
Hi!
Please, C++ gurus out there - help me, I think I'm gonna get crazy soon.
Finally I have decided to learn C++. 400 pages so far from Bjarne's
book. I can tell - it is a whole bunch of crap. I'm sure Bjarne can
desing C++ programs very well, but he cannot design a book, that's sure.
You just cannot find the thing that you need at the right place, it is
spread across 1600 pages. Find it - well thanks a lot :)
So, to the point. I have a question about a thing, that works with
Borland, and MSVC, but not with g++. Here it is:
I have a class, name it "myclass".
I have a function, which return "myclass".
I have a function, which uses "myclass".
Here they are:
//The class
class myclass{
public:
static void use_myclass(myclass& mc){ //The using function
printf("Value: %d\n",mc.value);
}
int value;
};
//The returner function
myclass make_myclass(void)
{
myclass mc_tmp;
return mc_tmp;
}
And so why the hell doesn't this work?:
int main()
{
myclass::use_myclass(make_myclass());
return 0;
}
WHILE THIS DOES:
int main()
{
myclass mc_tmp = make_myclass();
myclass::use_myclass(mc_tmp);
return 0;
}
The ONLY difference is, that I put the result in a temporary variable,
then I used that.
The compiler gave this warning to the first one:
test.cpp:19: no matching function for call to
`myclass::use_myclass(myclass)'
test.cpp:5: candidates are: static void myclass::use_myclass(myclass&)
So why the hell doesn't it make a reference from it then???
Please help me with this, I am at the bounds of getting crazy... really!
Thank you!
--
Greetings,
Balázs
|