Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Give me some advice about book and how to master vc and mfc!

Reply
Thread Tools

Give me some advice about book and how to master vc and mfc!

 
 
yuyazhang
Guest
Posts: n/a
 
      04-27-2006
Hi ,

I am a graduate , I have had some basic knowlege about C++ ! but
I find that I can't master it , I am disappoint for that . who give me
some advice about ways which master it and some good books 。I will
be pleasure.


Thank you in advance!


Zhang

 
Reply With Quote
 
 
 
 
benben
Guest
Posts: n/a
 
      04-27-2006
yuyazhang wrote:
> Hi ,
>
> I am a graduate , I have had some basic knowlege about C++ ! but
> I find that I can't master it , I am disappoint for that . who give me
> some advice about ways which master it and some good books 。I will
> be pleasure.
>
>
> Thank you in advance!
>
>
> Zhang
>


Well, grab a good book and read it down

Regards,
Ben
 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      04-27-2006
"yuyazhang" writes:

I am a graduate , I have had some basic knowlege about C++ ! but
I find that I can't master it , I am disappoint for that . who give me
some advice about ways which master it and some good books ?I will
be pleasure.

I'm not sure anyone has ever mastered C++, the language is huge, not pure,
and not really designed to my way of thinking. This leads to quirky
effects. By not pure, I mean object orientation is tacked on to the C
language and the result is a forced fit. Obviously has been and is very
successful despite these problems.

The best way to proceed that I know of is to work with _The C++ Programming
Language_ by Stroustrup, at least the third edition. Write lots of code,
and don't keep beating the same problem over and over which I think a lot of
people do. Writing you own string class is a good exercise if you haven't
already done so.


 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      04-27-2006
osmium wrote:

> The best way to proceed that I know of is to work with _The C++
> Programming Language_ by Stroustrup, at least the third edition.


The absolute worst way to learn C++ has got to be MFC.



--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
benben
Guest
Posts: n/a
 
      04-28-2006
> By not pure, I mean object orientation is tacked on to the C
> language and the result is a forced fit.


Can you be more specific about why C++'s object-oriented support is a
"forced fit"?

I am under the impression that you came to this conclusion because C++
does support non-OOP paradigms. Please prove me wrong.

Regards,
Ben
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      04-28-2006
benben wrote:

>> By not pure, I mean object orientation is tacked on to the C
>> language and the result is a forced fit.

>
> Can you be more specific about why C++'s object-oriented support is a
> "forced fit"?


I can. Some languages permit this (in pseudo-C++ syntax):

void foo(class & bar)
{
bar * frob = new bar;
...
}

I passed a class as an object into foo().

Because C++ must follow C's legacy compiler and linker technology, classes
are not objects. So we have two (mildly conflicting) syntaxes to do related
OO things. To pass an interface to a function, we can use inheritance. To
pass a class to a function, we must use template syntax. This is redundant -
two different systems to pass things to functions! Redundancy is a very
clear indicator of poor design.

Tip: Part of becoming fluent in programming is to let go of defensiveness
over languages. And about OO!

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
Noah Roberts
Guest
Posts: n/a
 
      04-28-2006

Phlip wrote:
> benben wrote:
>
> >> By not pure, I mean object orientation is tacked on to the C
> >> language and the result is a forced fit.

> >
> > Can you be more specific about why C++'s object-oriented support is a
> > "forced fit"?

>
> I can. Some languages permit this (in pseudo-C++ syntax):
>
> void foo(class & bar)
> {
> bar * frob = new bar;
> ...
> }
>
> I passed a class as an object into foo().
>
> Because C++ must follow C's legacy compiler and linker technology, classes
> are not objects. So we have two (mildly conflicting) syntaxes to do related
> OO things. To pass an interface to a function, we can use inheritance. To
> pass a class to a function, we must use template syntax. This is redundant -
> two different systems to pass things to functions! Redundancy is a very
> clear indicator of poor design.


That ability in other languages comes with several expenses including
type safety and runtime efficiency.

That is a fact...which is better is an opinion.

 
Reply With Quote
 
benben
Guest
Posts: n/a
 
      04-29-2006
> I can. Some languages permit this (in pseudo-C++ syntax):
>
> void foo(class & bar)
> {
> bar * frob = new bar;
> ...
> }


Let's say we do something with frob other than the dot dot dot:


void foo(class& bar)
{
bar* frob = new bar;
frob->do_trick();

delete frob;
}


Well, the problem is, what if class bar doesn't have a do_trick member
function? You are moving compile-time error to runtime error, which is
equivalent to letting the end users to deal with the error instead of
you dealing it. Not a wise move.

A type-safe alternative can be achieved in C++:

template <typename bar>
void foo(void)
{
bar* frob = new bar;
frob->do_trick();
delete frob;
}

Were bar not supporting the do_trick member, the compile will tell you.

Regards,
Ben
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      04-29-2006
benben wrote:

> Let's say we do something with frob other than the dot dot dot:
>
> void foo(class& bar)
> {
> bar* frob = new bar;
> frob->do_trick();
>
> delete frob;
> }
>
> Well, the problem is, what if class bar doesn't have a do_trick member
> function? You are moving compile-time error to runtime error, which is
> equivalent to letting the end users to deal with the error instead of you
> dealing it. Not a wise move.


Why can't the compiler just detect the use of class& and morph it into the
template expansion system currently used for template<class>?

(Because something could call the function that the compiler can't see yet,
unlike templates which have a fixed instantiation point, etc...)

The outer problem here is simply flexibility. I think having two redundant
systems to pass things into functions (either types or objects) is _less_
flexible than one unified system. Such unifications tend to force us to
invent the _weakest_ possible primitives, which then can be assembled in
new, emergent ways that language designers never thought of.

The inner problem is your unit tests should catch the error.

> A type-safe alternative can be achieved in C++:
>
> template <typename bar>
> void foo(void)
> {
> bar* frob = new bar;
> frob->do_trick();
> delete frob;
> }
>
> Were bar not supporting the do_trick member, the compile will tell you.


Can you do the Prototype Pattern with templates? The general point here is
that letting classes be objects makes many design patterns get shorter and
more trivial.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!


 
Reply With Quote
 
benben
Guest
Posts: n/a
 
      04-29-2006
Phlip wrote:
> benben wrote:
>
>> Let's say we do something with frob other than the dot dot dot:
>>
>> void foo(class& bar)
>> {
>> bar* frob = new bar;
>> frob->do_trick();
>>
>> delete frob;
>> }
>>
>> Well, the problem is, what if class bar doesn't have a do_trick member
>> function? You are moving compile-time error to runtime error, which is
>> equivalent to letting the end users to deal with the error instead of you
>> dealing it. Not a wise move.

>
> Why can't the compiler just detect the use of class& and morph it into the
> template expansion system currently used for template<class>?
>
> (Because something could call the function that the compiler can't see yet,
> unlike templates which have a fixed instantiation point, etc...)
>
> The outer problem here is simply flexibility. I think having two redundant
> systems to pass things into functions (either types or objects) is _less_
> flexible than one unified system. Such unifications tend to force us to
> invent the _weakest_ possible primitives, which then can be assembled in
> new, emergent ways that language designers never thought of.


While whether flexibility can be improved by making classes objects is
largely a subject of debate, I would point out that flexibility give way
to program correctness when they conflict.

>
> The inner problem is your unit tests should catch the error.


Why put an error to unit test while you could have eliminate it in the
first place?

And how are you so confident that your tests could catch all the errors?
I am not. And aren't you frustrated every time your browser pops up a
warning telling you some object doesn't support certain method? I am!

>
>> A type-safe alternative can be achieved in C++:
>>
>> template <typename bar>
>> void foo(void)
>> {
>> bar* frob = new bar;
>> frob->do_trick();
>> delete frob;
>> }
>>
>> Were bar not supporting the do_trick member, the compile will tell you.

>
> Can you do the Prototype Pattern with templates? The general point here is
> that letting classes be objects makes many design patterns get shorter and
> more trivial.


What does prototype pattern have to do with template? It can, of course,
be done in C++ with or without templates.

Type safety is a C++ feature. It is designed to restrict you from doing
something silly or inconsiderate in the first place. If you want to by
pass the type system you have to be explicit (so that you know what you
are doing)

As I said, flexibility gives way to correctness.

Regards,
Ben
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Give me some advice about some books of Java programing! yuyazhang Java 14 04-29-2006 11:13 AM
Give me some advice about book and how to master vc and mfc! yuyazhang C++ 0 04-27-2006 10:48 AM
Give me some advice about book and how to master vc and mfc! yuyazhang C++ 0 04-27-2006 10:48 AM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM



Advertisments