Hey! I liked Logo. In fact it was my first programming language. While playing with it I learned that procedures and functions are usefull. I even learned how to use recursion.Originally Posted by wysota
Hey! I liked Logo. In fact it was my first programming language. While playing with it I learned that procedures and functions are usefull. I even learned how to use recursion.Originally Posted by wysota
I didn't say I didn't like it I used to draw the alphabet using the turtle BASIC was my first language, though... I have been learning it more than 15 years ago on my ATARI 65XE box.
BASIC Code:
10 PRINT "Witek" 20 GOTO 10To copy to clipboard, switch view to plain text mode
I have actually never used logo at all...
I did load up KTurtle one day but it looked too complicated so I didn't mess with it much lol
const QString &signature = new QString("Katrina");
Wow, two errors on one line! "new QString" returns QString* and not QString and you can't assign a newly created object to a reference -- a reference is just a "handler" for already existing objects. But besides that -- niceOriginally Posted by katrina
Originally Posted by wysotaQt Code:
#include <iostream> class Test { public: Test() {} int foo() const { return 1; } }; int main() { const Test& t = Test(); std::cout << t.foo() << std::endl; return 0; }To copy to clipboard, switch view to plain text mode
Are you sure this is correct? You hold a reference to a temporary object here. The fact that it works in this case doesn't mean this is a correct statement.Originally Posted by jacek
What if you store the reference to that object as a member of some class?
Will compiler optimisations not affect the correctness of the above statement?
The secret lies in the "const" keyword.Originally Posted by wysota
yep, agreeOriginally Posted by jacek
And it's pretty useful.
Qt Code:
void foo(const string & s); //no 'const' whill lead to error foo("abc");To copy to clipboard, switch view to plain text mode
1. Users don't have the manual, and if they did, they wouldn't read it.
2. In fact, users can't read anything, and if they could, they wouldn't want to.
In this case this is only because there is a cast defined from const char* to const string.Originally Posted by bood
I wouldn't be so sure:Originally Posted by wysotaQt Code:
#include <iostream> #include <string> void foo( std::string& s ) { std::cerr << s << std::endl; } int main() { foo( std::string( "aaa" ) ); return 0; }To copy to clipboard, switch view to plain text mode
$ g++ -Wall a.cpp
a.cpp: In function `int main()':
a.cpp:11: error: invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::string'
a.cpp:5: error: in passing argument 1 of `void foo(std::string&)'
LOL Hey, I was trying to be funny, not syntactically correct! LOLOriginally Posted by wysota
QShutTheHeckUp *;-) = new QShutTheHeckUp;
(JUST KIDDING!)
sorry couldn't help myself :-D
Katrina
Bookmarks