Re: Visual C++ vs Visual C#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ben Voigt wrote:
My basic idea is that the first program should not contain any
language features which will not be taught immediately. I have a
big beef with java, where beginning programmers must learn a
15-ish-line incantation that seems to be magic (public class,
public static and array [] on main, System.out.println). I see the
idea of learning C++ without learning C to be fraught with the same
perils. The hello world program in a class on C++ should be as
simple as possible, which means this:
#include <stdio.h>

int main(void)
{
puts("Hello World!\n");
return 0;
}

Every single token in this program can be easily explained, there
is nothing that has to be learned by rote.

What?

What does .h mean in the include? A header, what's that?

What does void mean?

This \n thingy, what is that? Why doesn't it show up in the output?


Compare with a similar
"pure C++" program:
#include <iostream>

using namespace std;

int main(void)
{
cout << "Hello world" << endl;
return 0;
}

We've added namespaces and shift operators for no gain, and even

What shift operators? You mean the output operator? :-)


I guess you haven't looked into my favourite "Accelerated C++", which starts
with a gentle introduction in Chapter 0.

Quote

Let us begin by looking at a small C++ program:

// a small C++ program
#include <iostream>

int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}

End Quote


Nice, isn't it! :-)

It is definitely no harder to explain that std::cout is the standard output,
than it is to explain just what puts("\n") actually does. In the book, it
takes 3 pages to explain your first program - what happens and why.


Bo Persson



.



Relevant Pages

  • Re: Computing pi to nth terms?
    ... using namespace std; ... int main ... I'm learning as I go. ...
    (comp.lang.cpp)
  • Re: Some Advice.
    ... > int main{ ... Yes I am learning that and and implementing as I go along. ... you should provide inclusion guards for headers. ... > function definitions into separate source files. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: input and output questions about file
    ... using namespace std; ... junk.c:5: warning: type defaults to `int' in declaration of `std' ... junk.c:10: `string' undeclared ... junk.c:12: parse error before '/' token ...
    (comp.lang.c)
  • Re: Comparing files (Fast)
    ... I didn't knew what is was, but using fseek solved the problem. ... I'm using a timer utility Scott Meyers wrote for use ... > using namespace std; ... > int ch1,ch2; ...
    (comp.lang.cpp)
  • Re: return memory to the OS
    ... > 4 using namespace std; ... > 5 int main ... > possible to make STL return this memory to the OS (say using a system ... :: "out of confusion comes chaos -- out of chaos comes confusion and fear ...
    (comp.lang.cpp)