Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Practice of basic concepts

94 views
Skip to first unread message

TwistedRoar

unread,
Jan 1, 2014, 1:12:12 PM1/1/14
to
I'm quite new to C++, I started learning it a few days ago and, even though I do have some good studying material with me, I feel I lack a lot of practice...is there any online tutorial with activities or anything like that you could recommend me?

Jorgen Grahn

unread,
Jan 1, 2014, 1:50:11 PM1/1/14
to
On Wed, 2014-01-01, TwistedRoar wrote:
> I'm quite new to C++, I started learning it a few days ago

Good choice, congratulations!

> and, even
> though I do have some good studying material with me, I feel I lack a
> lot of practice...is there any online tutorial with activities or
> anything like that you could recommend me?

What material do you have? Many books come with exercises. The ones
from Stroustrup's latest edition are available from his web site:

http://www.stroustrup.com/4th.html

Probably a good choice, even if you don't own the book.

If you prefer to write real programs, one idea is to implement parts
of the Unix dc(1) command (it's a RPN calculator).

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Alf P. Steinbach

unread,
Jan 1, 2014, 2:08:30 PM1/1/14
to
Or the hoc[1] (which I suspect was really short for "ad hoc", not as was
claimed "high order calculator") calculator, which was the main
multi-stage example in the old "The Unix Programming Environment" book
by Brian Kernighan and, I think it was, Robert Pike.

It was developed in C with typical Unix toolset, including yacc and lex
(IIRC).

I think it could be instructive if someone redid all that with C++ and
modern portable toolset (which is not necessarily better in any way).


Cheers,

- Alf

Notes:
[1] See e.g. <url:
http://en.wikipedia.org/wiki/Hoc_%28programming_language%29>

TwistedRoar

unread,
Jan 1, 2014, 2:09:37 PM1/1/14
to
I had already heard a lot about that book, I'm going after it right now. Thank you!

Ernest G. Dakota

unread,
Jan 1, 2014, 2:35:09 PM1/1/14
to
TwistedRoar wrote:

> I had already heard a lot about that book, I'm going after it right now.
> Thank you!

Waste of time. Never fall for this shit.
Focus on what you want to do, then do exactly that.



--
Deut. 23:1 No man whose testicles have been crushed or whose organ has
been cut off may become a member of the Assembly of God.



-

Alf P. Steinbach

unread,
Jan 1, 2014, 2:40:33 PM1/1/14
to
There is a problem with online instruction material for C++: it's
generally FLAWED.

Very embarrassingly this was so even for MIT's first open courseware
about C++. It was full of Herb Schildt-like stuff, someone's creatively
invented facts, explanations and rationales, not to mention the
practices. They redid the courseware a year or two later with fewer
outright errors and less dis-information and bad practices, but still
that was (and probably still is) rather ungood, as I recall.

I once wrote the at that time only known /correct/ C++ tutorial,
unfinished but still. At that time the FAQ, for the
alt.comp.lang.learn-c-c++ newsgroup I think it was, mentioned that there
were no reliable, sufficiently correct C++ tutorials to find online,
which maybe was a result of the 1998 standardization radically changing
many aspects of C++, including header names! My tutorial ended up, as
the only one, in the C++ FAQ, that is, Marshall Cline's FAQ Lite.

In recent years, I think we're talking 4-5 years here, the quality has
improved, while my tutorial has first moved (as e.g. start.no free
hosting was discontinued) and then disappeared. Today I think the main
basically OK and reasonably complete online tutorial is the one at

http://www.cplusplus.com/doc/

However, the cplusplus site as a reference site is not so good. Instead
most people prefer the newer cppreference site (better quality). If
you're programming for Windows then Microsoft's MSDN Library (online) is
also a nice reference resource, as long as one keeps in mind that it's
not always very clear on what is Microsoft and what is standard, and
also that nearly all Microsoft example code is abomination-like.

I know almost nothing about the tutorial(s) at cppreference.com, but
even if they are of better quality than cplusplus.com, as is probable,
at a glance it seems to be very unfinished. Anyway, you find that at

http://en.cppreference.com/book

Finally, if you prefer to learn with this newsgroup as support then I
and others can suggest concrete exercises and discuss your solution
attempts. :-)

As an example, in order to learn the basics of stream i/o, which you'll
need for most all other exploration,

Exercise 1 (formatted stream output)
Display a 10*10 multiplication table, nicely formatted.

Then if you post the code here, then we can review it. It should be
small enough to post directly in-message.

Cheers & hth.,

- Alf

osmium

unread,
Jan 1, 2014, 2:43:55 PM1/1/14
to
"Ernest G. Dakota" wrote:

> --
> Deut. 23:1 No man whose testicles have been crushed or whose organ has
> been cut off may become a member of the Assembly of God.

Is that a reward or a punishment?


Message has been deleted

Alf P. Steinbach

unread,
Jan 1, 2014, 3:17:21 PM1/1/14
to
On 01.01.2014 21:02, Stefan Ram wrote:
> "Alf P. Steinbach" <alf.p.stein...@gmail.com> writes:
>> Display a 10*10 multiplication table, nicely formatted.
>
> ::std::cout << /* not tested */
> " | 0 1 2 3 4 5 6 7 8 9\n"
> "--|----------------------------------------\n"
> " 0| 0 0 0 0 0 0 0 0 0 0\n"
> " 1| 0 1 2 3 4 5 6 7 8 9\n"
> " 2| 0 2 4 6 8 10 12 14 16 18\n"
> " 3| 0 3 6 9 12 15 18 21 24 27\n"
> " 4| 0 4 8 12 16 20 24 28 32 36\n"
> " 5| 0 5 10 15 20 25 30 35 40 45\n"
> " 6| 0 6 12 18 24 30 36 42 48 54\n"
> " 7| 0 7 14 21 28 35 42 49 56 63\n"
> " 8| 0 8 16 24 32 40 48 56 64 72\n"
> " 9| 0 9 18 27 36 45 54 63 72 81\n";

This illustrates the nice difference between learning and modern
education, I think.

Also it nicely illustrates how to (not) interpret requirements. The
small multiplication table's upper leftmost item is most often 1, and
lower right item is nearly always 100. A host of examples here:

https://www.google.com/search?q=10+by+10+multiplication+table&tbm=isch

If the OP (or some other learned) posted this code, I think group
members would applaud the creativity, but would then focus on whether
the choice helped to learn anything about formatted output, and how easy
it would be to adapt the solution to, say, showing a 20*20 table.


Cheers,

- Alf

Alf P. Steinbach

unread,
Jan 1, 2014, 4:32:49 PM1/1/14
to
On 01.01.2014 20:35, Ernest G. Dakota wrote:
> TwistedRoar wrote:
>
>> I had already heard a lot about that book, I'm going after it right now.
>> Thank you!
>
> No man whose testicles have been crushed or whose organ has
> been cut off may become a member of the Assembly of God.

plink

Jorgen Grahn

unread,
Jan 1, 2014, 4:53:25 PM1/1/14
to
On Wed, 2014-01-01, Ernest G. Dakota wrote:
> TwistedRoar wrote:
>
>> I had already heard a lot about that book, I'm going after it right now.
>> Thank you!
>
> Waste of time. Never fall for this shit.
> Focus on what you want to do, then do exactly that.

Unless you follow that up with a proper explanation, I count that as
trying to mislead a newbie coming here for advice. A rotten thing to
do.

Ernest G. Dakota

unread,
Jan 1, 2014, 4:55:57 PM1/1/14
to
Jorgen Grahn wrote:

> On Wed, 2014-01-01, Ernest G. Dakota wrote:
>> TwistedRoar wrote:
>>
>>> I had already heard a lot about that book, I'm going after it right
>>> now.
>>> Thank you!
>>
>> Waste of time. Never fall for this shit.
>> Focus on what you want to do, then do exactly that.
>
> Unless you follow that up with a proper explanation, I count that as
> trying to mislead a newbie coming here for advice. A rotten thing to
> do.

No, you are simply a lying imbecile. Trying to sell products? What a lame
thing to do on usenet. Shame


--
Leviticus 20:15 If a man has sex with an animal, he must be put to death,
and the animal must be killed. (NLT)



-

Melzzzzz

unread,
Jan 1, 2014, 5:00:26 PM1/1/14
to
I think that's quote from Bible.

--
Have a place for everything and keep the thing somewhere else; this is
not advice, it is merely custom.
-- Mark Twain

David Brown

unread,
Jan 2, 2014, 1:38:30 AM1/2/14
to
On 01/01/14 22:55, Ernest G. Dakota wrote:
> Jorgen Grahn wrote:
>
>> On Wed, 2014-01-01, Ernest G. Dakota wrote:
>>> TwistedRoar wrote:
>>>
>>>> I had already heard a lot about that book, I'm going after it right
>>>> now.
>>>> Thank you!
>>>
>>> Waste of time. Never fall for this shit.
>>> Focus on what you want to do, then do exactly that.
>>
>> Unless you follow that up with a proper explanation, I count that as
>> trying to mislead a newbie coming here for advice. A rotten thing to
>> do.
>
> No, you are simply a lying imbecile. Trying to sell products? What a lame
> thing to do on usenet. Shame
>

You do realise that Jorgen is not selling anything here? He is pointing
to some useful exercises available freely online, along with a book by
the guy that made the C++ language. (That does not necessarily imply
that Stroustrup writes the best C++ books - though it turns out that he
/does/ write good books.)

Focusing on a particular aspect of C++ could be a good idea - if the OP
wants to write games, then a book on "C++ for games development" might
be a good choice. But at the moment he is looking for general C++ help
and pointers, and that is what he has been getting here.

Victor Bazarov

unread,
Jan 2, 2014, 8:52:55 AM1/2/14
to
On 1/1/2014 3:02 PM, Stefan Ram wrote:
>[..]
> ::std::cout << /* not tested */
> " | 0 1 2 3 4 5 6 7 8 9\n"
> "--|----------------------------------------\n"
^^^^^
I'd use a plus instead of the vertical line here.

> " 0| 0 0 0 0 0 0 0 0 0 0\n"
> " 1| 0 1 2 3 4 5 6 7 8 9\n"
> " 2| 0 2 4 6 8 10 12 14 16 18\n"
> " 3| 0 3 6 9 12 15 18 21 24 27\n"
> " 4| 0 4 8 12 16 20 24 28 32 36\n"
> " 5| 0 5 10 15 20 25 30 35 40 45\n"
> " 6| 0 6 12 18 24 30 36 42 48 54\n"
> " 7| 0 7 14 21 28 35 42 49 56 63\n"
> " 8| 0 8 16 24 32 40 48 56 64 72\n"
> " 9| 0 9 18 27 36 45 54 63 72 81\n";
>

V
--
I do not respond to top-posted replies, please don't ask

Luca Risolia

unread,
Jan 4, 2014, 7:45:40 PM1/4/14
to
Stefan Ram wrote:

> "Alf P. Steinbach" <alf.p.stein...@gmail.com> writes:
>>Display a 10*10 multiplication table, nicely formatted.
>
> ::std::cout << /* not tested */
> " | 0 1 2 3 4 5 6 7 8 9\n"
> "--|----------------------------------------\n"
> " 0| 0 0 0 0 0 0 0 0 0 0\n"
> " 1| 0 1 2 3 4 5 6 7 8 9\n"
> " 2| 0 2 4 6 8 10 12 14 16 18\n"
> " 3| 0 3 6 9 12 15 18 21 24 27\n"
> " 4| 0 4 8 12 16 20 24 28 32 36\n"
> " 5| 0 5 10 15 20 25 30 35 40 45\n"
> " 6| 0 6 12 18 24 30 36 42 48 54\n"
> " 7| 0 7 14 21 28 35 42 49 56 63\n"
> " 8| 0 8 16 24 32 40 48 56 64 72\n"
> " 9| 0 9 18 27 36 45 54 63 72 81\n";

::std::cout << R"(
| 0 1 2 3 4 5 6 7 8 9
--+----------------------------------------
0| 0 0 0 0 0 0 0 0 0 0
1| 0 1 2 3 4 5 6 7 8 9
2| 0 2 4 6 8 0 12 14 16 18
3| 0 3 6 9 12 15 18 21 24 27
4| 0 4 8 12 16 20 24 28 32 36
5| 0 5 10 15 20 25 30 35 40 45
6| 0 6 12 18 24 30 36 42 48 54
7| 0 7 14 21 28 35 42 49 56 63
8| 0 8 16 24 32 40 48 56 64 72
9| 0 9 18 27 36 45 54 63 72 81
)";

0 new messages