Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Потрепаться";
Текущий архив: 2003.04.10;
Скачать: [xml.tar.bz2];

Вниз

Frequently Unanswered Questions   Найти похожие ветки 

 
Oleg_Gashev   (2003-03-23 23:08) [0]

A lot of questions posted to comp.lang.c++ go unanswered. Here are some of
the answers straight from the beta version of the C++ Lame-O-Matic:
---
#1 Q. I have to learn C++ by tomorrow morning at nine. A big $$
job/contract/final exam depends on this. Where should I start?
A. You are about to learn a valuable lesson: don"t lie TOO much on your
resume, and don"t take drugs before job interviews.

#2 Q. I need to convert 100,000 lines of Visual Basic to C++ by next
Friday. What books and tools can I get to help?
A. There are several varieties of psychoactive mushrooms you can use to
convert almost any language to any other language in less than an hour.

#3 Q. Where can I get a book on C++?
A. Most bookstores sell them; lately Safeway and 7-11 have been stocking
some C++ books as well. You will have to get off your butt and out of the
newsgroups and PHYSICALLY go somewhere. Unfortunately most bookstores
can"t order books that they don"t already have, nor do they have catalogs
of books in print, so you may be out of luck.

#4 Q. Where can I buy a C++ compiler for my computer?
A. C++ compilers are distributed by Bjarne Stroustrup, and are only given
to programmers who can pass a multiple-choice test with an essay question
at the end. Contact the C++ Overlords for testing dates and sites.

#5 Q. I learned Pascal in school and now I"m learning C++ on my PC at
home. How do I translate my code from Pascal to C++?
A. Any good C++ compiler can directly read and compile correct Pascal,
Basic, COBOL, and Fortran code--C++ is a superset of all other languages.
If your compiler is giving you errors you either have bugs in your code or
one of your IRQ settings is wrong.

#6 Q. I installed Borland C++ 4.5 on my PC and now I get hundreds of
compiler errors when I try to compile my code. Does Borland"s compiler
suck? Should I get a refund?
A. Remember that C++ is not a fully standardized language at this point.
There are several common C++ constructs that aren"t supported by the
Borland compiler. In particular, the assignment operator (=) is not
supported, the "int" and "char" types don"t work, the left brace character
"{" must be globally changed to an "@", etc. Borland knows about these
problems and will be releasing a fix sometime soon. A full list of
incompatibilities is available from ftp.whitehouse.gov.borland.c++.errata.

#7 Q. I want to add the "@" operator to plot points and the "^" operator
to perform exponentiation. How can I do this in C++?
A. operator* plot_point = new("@");
operator* exponentiate = new("^");
Note that not all compilers support this syntax yet; refer to the ARM.

#8 Q. Now that you mention it, what the heck is the ARM?
A. The Association for Reaming Machines, the public-interest division of
the C++ Directorate, which is managed by the C++ Overlords. The ARM is
responsible for forcing all programmers in the world to use C++ and to
renounce all other languages. Their official procedure manual was released
in bootleg form by Addison-Wesley and is commonly called "The Gray Book."

#9 Q. What is OOP?
A. The singular form of OOPS. It is archaic in modern English.

#10 Q. How can I read and write to the modem port in C++? I used to be
able to do this with BASIC.
A. C++ does not support writing to devices or files--simply include your
BASIC code in a header file.


 
Oleg_Gashev   (2003-03-23 23:09) [1]

#11 Q. In the code below why doesn"t i equal f?
int i = 3;
float f = 0.3333333 * 3;
if ( i == f ) ...
A. In C and C++ integers are not always exact; it"s not possible to
represent all integers in binary form. Use floating-point numbers when you
need to compare for equality.

#12 Q. How can I draw to the screen with C++? I have to write a fractal
program to get an "A" for this term.
A. See #7 above and define the "@" operator to plot points to the screen.
Or define a class to draw fractals and stuff and just use that. The
essence of object oriented programming is to use black-box classes.

#13 Q. Isn"t C++ a lot slower than Pascal because it lets you have a
variable number of arguments passed to a function?
A. No--in fact C++ is FASTER than Pascal. Because C++ can"t always know
how many parameters there are, it doesn"t have to worry about pushing them
onto the stack--it is the called function"s responsibility to get the
parameters. Most C++ programmers use references for this. This is a
significant savings because studies show that most programs spend almost
85% of their executing time pushing and popping function parameters.

#14 Q. I wrote a function and made it inline, but I"m not sure what this does.
A. Don"t use inline unless you know what you are doing--you could get
hurt. The "inline" keyword tells the compiler it is OK to generate every
other bit for the function. [In "The Design and Evolution of C++"
Stroustrup explains this and how inlining was added to C++ after he got a
pair of rollerblades for his birthday!]

#15 Q. I need a string class--do I have to write my own?
A. Unfortunately no commercial C++ compilers come with any standard string
class, so you do have to write your own.

#16 Q. How do I write a string class?
A. Here"s a "baby string" class that will get you started:

class string {
private:
char *s;

public:
string(char *t) { strcpy(s, t); }
~string() { delete s; }
};

Note: some users have reported run-time errors with this code--make sure
to read all compiler warnings.

#17 Q. What is the difference between a reference and a pointer?
A. There is no difference--the ARM says that the & character looks nicer
than the *.

#18 Q. What is the difference between delete and delete []?
A. On most compilers there is no difference. According to the Microsoft
Systems Journal you MUST use delete and NOT delete [] when deleting an
array of a built-in type such as int or char.

#19 Q. What is Delphi and how is it different from C++?
A. Delphi is a version of C++ that looks like Pascal with some
object-oriented extensions.

#20 Q. Is C++ a pure object-oriented language?
A. Yes. All other so-called OO languages are based on C++. Smalltalk is
the best example of an impure OO language.


 
Oleg_Gashev   (2003-03-23 23:10) [2]

#21 Q. What is "Turing complete?"
A. Everyone has their opinions on this. I like a BMW motorcycle with hard
luggage and heated grips.

#22 Q. Why are there so many off-topic questions in comp.lang.c++?
A. Some people, mostly from America Online, think that comp.lang.c++ is
for discussing the C++ lanaguge and they fill up the newsgroup with
postings that are irrelevant for most people. Of course the purpose of
programming is to get a job done, and comp.lang.c++ was established to
give people a single place to ask and answer questions about their
particular computer, printer, keyboard, compiler, operating system, and
even other languages that they might be familiar with. To avoid being
flamed make sure your postings are about real-world problems like how to
print to a Panasonic printer and NOT just academic ramblings and ravings
and a bunch of useless "theory."

#23 Q. I was fired from my job because I used "while (*s++ = *t++);".
What"s wrong with that?
A. A long time ago some anarchists published a book called "K&R" which
espoused certain bad programming practices. Over time many of these
practices insinuated themselves into C and C++ code because of a few idiot
programmers (thus the term "idiom" to describe these bad techniques). Your
manager was right to fire you; code like that is obscure and no C/C++
programmer would be able to figure it out. It"s always safest to comment
EVERY LINE OF CODE and to avoid C"s more obscure control constructs. For
example, this code is much better:

Start_Of_Copy_Loop: if (*t == "\0") goto End_Of_Copy_Loop;
c = *t; /* get a char from t */
*s = c; /* store char in s */
s = s + 1; /* increment s */
t = t + 1; /* increment t */
goto Start_Of_Copy_Loop; /* loop */
End_Of_Copy_Loop: c = "\0"; /* get end-of-string character */
s = s + 1; /* move to end of s */
*s = c; /* store end of string character */

Not only is this easier to read but it is MUCH faster.

#24 Q. How can I play a sound with C++? I"m using Visual C++ 2.0.
A. Use the standard library function "memcpy" to copy your sound to the
sound card.

#25 Q. I tried memcpy and I check all of my IRQs, DMA channels, CONFIG.SYS
and AUTOEXEC.BAT settings and I still can"t play a sound from C++. I think
C++ sucks.
A. Whoa there! C++ directly supports sound, just like C. I"m not aware of
any commercial C or C++ compiler that can"t play a sound. If you are sure
your sound hardware is working and that there are no bugs in your code,
make sure you are passing a valid sound object to memcpy.



 
Oleg_Gashev   (2003-03-23 23:11) [3]

#26 Q. The following code gives me different results depending on what
kind of computer I run it on. My "Learn C++ in 21 Days" book says
something about undefined order of evaluation. What does that mean?
int i = 1;
i++ = i++ + 2;
A. The + operator is not defined for the built-in types, so you have to
overload the + operator. Your example has five + operators in it, which is
five undefined evaluations--no wonder you are getting different results!

#27 Q. Why does my book say ++i is faster than i++?
A. There is a language very similar to C++ called ++C, which uses the
prefix notation (++i). ++C is generally faster than C++ because it doesn"t
have built-in support for sound or printers.

#28 Q. My compiler uses malloc() to implement the global new operator and
free() for the global delete operator. Can I just use free() to delete an
object I allocated with "new"?
A. Yes, and this is a good way to avoid destructor calls that take a long time.

#29 Q. How can I port my Windows application to the Macintosh? It"s
written in C++.
A. Unfortunately you can"t--the Macintosh is not a serious computer. Not
only aren"t there any C++ compilers for the Macintosh, but the Mac can"t
read standard DOS diskettes or text files. There is no serious business or
programming software for the Macintosh, only paint programs and fonts.

#30 Q. When I try to create an array of 100,000 objects that are 100 bytes
each my program crashes with an out of memory error. I have a 250 megabyte
hard disk. Why does C++ do this?
A. Instead of using "T* t = new T[100000]" declare "t" as a local
variable. Local variables are allocated on the stack (new allocates from
the heap). A heap is like a box--there"s only so much room in it. A stack
is like a pile of plates--you can make it taller simply by stacking more
plates on top.

#31 Q. My program compiles OK but when I run it my computer locks up. Why
does C++ do this?
A. This happens on all kinds of computers and with all kinds of programs.
It"s not really a C++ problem, but it is a problem C++ inherited from C.
The designers of C++ felt it was very important for C++ to be compatible
with the millions of lines of existing C code, so C++ programs crash just
like C programs do. When operating systems have protected memory a lot of
these problems will go away.

If your question was answered in this document, great--you are on your way
to being a professional C++ programmer. If your question wasn"t answered
keep posting it into comp.lang.c++ and I will try to answer it in the next
FUQ.
--
Gregory Jorgensen
radix consulting inc
radixinc@aol.com, radix@efn.org


 
Neox   (2003-03-23 23:16) [4]

#19 Q. What is Delphi and how is it different from C++?
A. Delphi is a version of C++ that looks like Pascal with some
object-oriented extensions.

=)))

жалко это не здесь ляпнули, а так бы в орешник можно было бы.


 
Ixion   (2003-03-23 23:45) [5]


> Oleg_Gashev © (23.03.03 23:11)


А что просто ссылку не судьба было дать ?


 
XeN   (2003-03-24 00:09) [6]

ИМХО некоторое даже не смешно.


 
Asteroid   (2003-03-24 01:07) [7]

Какой-то плоский у них юмор.



Страницы: 1 вся ветка

Форум: "Потрепаться";
Текущий архив: 2003.04.10;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.48 MB
Время: 0.007 c
3-30251
Yuraz
2003-03-20 10:42
2003.04.10
Мост перекачки данных FoxPro > Oracle с помощью чего организовать


14-30588
Интересующийся
2003-03-25 20:43
2003.04.10
Операции AND и OR


3-30211
volodya_
2003-03-20 17:21
2003.04.10
Перекодировка Win->Dos и Dos->Win


1-30422
любитель
2003-03-31 05:24
2003.04.10
Можно ли сделать бесконечный цикл в Delphi


6-30493
DimonZh
2003-02-18 20:21
2003.04.10
Wake On Lan





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский