Re: cpp help!

  • From: Alex Midence <alex.midence@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Thu, 26 Aug 2010 23:59:35 -0500

Best friend huh?  I'll take your word on it for now.  They just seem
like abloody fine way to shoot yourself in the foot.  Bet you can do
some serious damage to your pc if you screw up.

Alex M

On 8/26/10, Littlefield, Tyler <tyler@xxxxxxxxxxxxx> wrote:
> Pointers are never easy--I tried the whole "I'll never use them," route. But
> I soon realized everything uses them. After you learn them, they'll be your
> best friend.
>
> I like the analogy, BTW. Never thought of it that way.
>
> ----- Original Message -----
> From: "qubit" <lauraeaves@xxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Thursday, August 26, 2010 7:51 PM
> Subject: Re: cpp help!
>
>
>> Ty is right -- even the supposedly special syntax
>>  cout << data << endl;
>> is not part of the language, but the operator<< is overloaded for usage
>> that
>> way in the iostream
>> library.
>> Learning the language is separate from learning the libraries you want to
>> use.
>> This is true in any OO language, including java, C#, python or whatever.
>>
>> For example, I am learning java right now, and java has 2 popular
>> libraries
>> for handling its I/O -- one is SWING and the other SWT.  There are pros
>> and
>> cons to both. But if you know one, it may still take you a little bit of a
>> learning curve to switch to the other.  It's just unavoidable.
>>
>> Back to C and C++, I have some handy analogies for understanding and using
>> pointers.
>>
>> First was one a professor related in a class I took ages ago -- suppose
>> you
>> are on a treasure hunt and the map leads you to a box. The box could
>> either
>> hold the goods you are seeking, or the location where to find the next
>> clue.
>> If it is a location, you could say it points to a new destination.  So
>> it's
>> a pointer.
>>
>> Second observation, in C and therefore C++, the syntax for a declaration
>> of
>> a variable is designed to mimick what an expression would look like if you
>> wanted to access data through that variable.
>> Let me sho some examples:
>>
>> int i; // i contains the int
>> int *p;  // if you want the pointer int*, just say p, but if you want to
>> get
>> to the int, just say *p, as suggested by the declaration.
>>
>> Now here's a trickier one:
>>
>> int *p[5];
>> int (*q)[5]);
>>
>> How would you use these in an expression?
>> If you want to get to an int in the array of pointers to int, the
>> expression
>> for p would be
>> *p[3]
>> just like the declaration.
>> (Note: the array reference is evaluated before the * as it has higher
>> operator precedence.)
>>
>> But what about q? What is q? Well, answer that by writing expressions that
>> access q:
>> q // points to something
>> *q according to the declaration, is an array
>> *q[3] is an error because it treats q as an array when it is just a
>> pointer
>> to an array.
>> (*q)[3] eureka! you have the int
>>
>> Pointers and other low level constructs are important in C because C was
>> originally developed as a semi-high level language for writing operating
>> systems, and therefore the programmer needed to have access as close as
>> possible to the hardware while still remaining portable.
>>
>> C++ inherited a lot of the low level stuff, and kept it in the language
>> for
>> backward compatibility, which was as much a business consideration as a
>> technical one -- C programs had to compile with the C++ compiler with only
>> minor changes, or else people might not use it.
>> So that's why we have the mess we all know and love *smile*
>>
>> The learning curve for C# and VB I believe is a little easier because of
>> the
>> IDE which has templates of common code configurations built into the
>> editor
>> that you can pull down.
>>
>> Haappy hacking.
>> --le
>>
>> ----- Original Message -----
>> From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
>> To: <programmingblind@xxxxxxxxxxxxx>
>> Sent: Thursday, August 26, 2010 7:43 PM
>> Subject: Re: cpp help!
>>
>>
>> The C++ specification, or C++ in itself, is platform independent. The STL
>> and CRT are implemented BY THE compiler your using, for each platform.
>> Each
>> call is set so that code can be portable, but the code between windows and
>> Linux, gcc and visual studio for the CRT and STL isn't the same. The
>> library
>> just makes system calls, which are implimented by the platform itself.
>>
>> C++ being independent, and with the CRT and STL not technically being part
>> of the C++ language, it would make no sense to provide a GUI library.
>>
>> So I guess I'm confused as to what your wanting. C++ -is- not geared only
>> toward console applications. As I said, it is a low-level language. The
>> usage of libraries is what makes it powerful. If using libraries and
>> reading
>> documentation is a problem for you, I suggest you find something else--the
>> info gathered from what you've learned about c++ minus the asumptions will
>> help you.
>>
>> As the CRT and STL are just their own libraries (which are written per
>> compiler), I don't see the issue with using a GUI library as well.
>> Technically, your making library calls when you do printf, cout, etc etc.
>>
>> And... what's this?
>> "dlg <preferences>" I'm not quite sure where that fits into the c++
>> language
>> at all...
>> It's almost like your trying to make c++ be more than it is. C++ is just
>> the
>> language; the libraries are what exposes the functionality that your using
>> even now.
>>
>> Thanks,
>> Ty
>> ----- Original Message -----
>> From: "Alex Midence" <alex.midence@xxxxxxxxx>
>> To: <programmingblind@xxxxxxxxxxxxx>
>> Sent: Thursday, August 26, 2010 5:54 PM
>> Subject: Re: cpp help!
>>
>>
>>> Hello,
>>>
>>> I think you need to reread my message, Tyler. I never said I thought
>>> pointers were useless.  I said I personally couldn't imagine myself
>>> ever needing them.  I then proceeded to list instances where I thought
>>> someone else might use them.  Another poster who happens to share my
>>> name said he saw them and understood why other languages dispensed
>>> with them which is where I think you were thrown off.  Secondly, other
>>> languages seem to allow the user to learn how to write gui
>>> applications at a much earlier stage in the learning process than c++
>>> does.  I do realize it is a low level language.  My point was why
>>> doesn't it include some of the gui-producing libraries in its standard
>>> library?  Why can there not be an incorporation of all the gui
>>> toolkits out there into the standard library along with some sort of
>>> way to create them using a built-in type or even a type specified in
>>> the library as is the case with string.  This is a clumsy example but:
>>>
>>> cout << "This is a message.";
>>>
>>> could have something like this analogous to it:
>>>
>>>
>>> msg_box << "This is a message.";
>>>
>>> Or, another thing:
>>>
>>> dlg <preferences>
>>> {
>>> chgx background;
>>> chbx font;
>>> chbx icons;
>>> btn ok;
>>> btn cancel;
>>> ... definitions and manipulations could then follow
>>> }
>>>
>>>
>>> Windows and controls would have a default set of specifications that
>>> set the window size, its placement on the screen, and a generic
>>> foreground and background which could perhaps be changed by the
>>> developer with parameters.
>>>
>>> The way it's set up now, you have to use nonstandard libraries which
>>> are, in fact, written in c or some other language like that to make a
>>> gui program.  If you use the pure standard library form of c++, you
>>> can make some nice utilities it seems along with all sorts of console
>>> applications that most people do not want to use.  I'm sure there are
>>> ways to make graphics with it but, I only keep  finding references to
>>> them in game programming.  I am not interested in writing games
>>> text-based or otherwise.  I want to work with business applications.
>>> Hence my question, did I choose the wrong language?  Have I wasted my
>>> time?  Is this a language that is actually going to become obscelete
>>> in a few years because the core of the language seems so heavily
>>> geared towards console applications in a world where gui is what most
>>> end users want.
>>>
>>> Alex M
>>>
>>> On 8/26/10, Littlefield, Tyler <tyler@xxxxxxxxxxxxx> wrote:
>>>> Um, they're not murder, and the fact that you haven't found a use for
>>>> pointers doesn't make them useless. They can be very powerful.
>>>>
>>>> Second, you want to run before you've learned to crawl. C++ -is-,
>>>> amazingly
>>>> enough a low-level language.
>>>> Yes, this does mean more code, but it's not all that much once you get
>>>> down
>>>> to learning what it does.
>>>> No, you will not find a tutorial that teaches you to write a hello world
>>>> program in a GUI and be able to learn c++ while you also learn gui
>>>> programming--it just won't happen. There may be something, but the fact
>>>> is,
>>>> you need to understand the language before you start using libraries
>>>> such
>>>> as
>>>> the windows API.
>>>>
>>>> ----- Original Message -----
>>>> From: "Alex Midence" <alex.midence@xxxxxxxxx>
>>>> To: <programmingblind@xxxxxxxxxxxxx>
>>>> Sent: Thursday, August 26, 2010 3:50 PM
>>>> Subject: Re: cpp help!
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> They're murder!  I can't imagine when I'd want to use one in an
>>>>> application short of some cellphone app for antiquated models.
>>>>> Pointers are a bit scary.  What really gets me about c++ is what a
>>>>> pain it is to write a gui application in it.  It is an undeniable fact
>>>>> that most people want to use gui applications whether it's for
>>>>> windows, gnome, or Mac.  Console applications make your average end
>>>>> user flinch away in horror.  Why then, isn't there a standard library
>>>>> component that quickly and efficiently addresses writing gui
>>>>> applications in c++ without requiring about 70 or 80 lines of code for
>>>>> a Hello World application that takes like 10 lines to write in console
>>>>> form?  I don't buy the whole platform constraint argument.  I can see
>>>>> that for the windows api but qt, gtk+ and wx widgets are all touted as
>>>>> cross-platform gui libraries that make your application portable and
>>>>> keep much of the same look and feel regardless of where they are
>>>>> deployed.  Instead you have to spend lots and lots of time slogging
>>>>> your way through tutorials that teach you pages and pages of code
>>>>> using things like iostream, cmath, fstream, string, conio, and cstdlib
>>>>> instead of oh,  I don't know, windows.h, wxsetup.h, and so forth which
>>>>> appear to be the sorts of things you need to make a real application
>>>>> somebody might actually want to use some day.  Just got through
>>>>> reading a book by Herb Schildt last night.  Has 12 chapters of this
>>>>> sort of thing.  He's got another that has even more chapters about it.
>>>>> It takes some serious digging to find a c++ manual that teaches you
>>>>> how to write gui apps and most of them are written by volunteers and
>>>>> are consequentially sketchy, and at times poorly written.  Before bed,
>>>>> I then opened up a Teach Yourself Java in 24 hours and there's a gui
>>>>> app close to the middle of the book using swing for me to write which
>>>>> I will probably be able to do saturday.  Can anyone shed some light on
>>>>> the madness?  Did I choose a language that is over the hill?  Have the
>>>>> past months I've spent on c++ been a total waste?
>>>>>
>>>>> Alex M
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 8/26/10, Alex Hall <mehgcap@xxxxxxxxx> wrote:
>>>>>> Thanks. There is a good tutorial there... I can see why pointers have
>>>>>> been left behind in newer languages!
>>>>>>
>>>>>> On 8/26/10, qubit <lauraeaves@xxxxxxxxx> wrote:
>>>>>>> www.cplusplus.com is good
>>>>>>> ----- Original Message -----
>>>>>>> From: "Alex Hall" <mehgcap@xxxxxxxxx>
>>>>>>> To: "programmingblind" <programmingblind@xxxxxxxxxxxxx>
>>>>>>> Sent: Thursday, August 26, 2010 12:39 PM
>>>>>>> Subject: cpp help!
>>>>>>>
>>>>>>>
>>>>>>> Hi all,
>>>>>>> I am working with a few other people on a project. I am the only one
>>>>>>> that speaks Python and Java, not cpp. We hope to package this as an
>>>>>>> executable, so cpp makes the most sense, plus some source code we
>>>>>>> hope
>>>>>>> to use as part of the project is written in c already. Does anyone
>>>>>>> know of any tutorials for cpp, mainly about classes, objects,
>>>>>>> subclassing, file streams, and other semi-advanced topics? I know how
>>>>>>> to do the basics, like conditionals or functions, but that is it.
>>>>>>> Again, I was taught Java through my first two years of college, then
>>>>>>> I
>>>>>>> found, and fell in love with, Python and have used that as my primary
>>>>>>> language since January.
>>>>>>>
>>>>>>> --
>>>>>>> Have a great day,
>>>>>>> Alex (msg sent from GMail website)
>>>>>>> mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
>>>>>>> __________
>>>>>>> View the list's information and change your settings at
>>>>>>> //www.freelists.org/list/programmingblind
>>>>>>>
>>>>>>> __________
>>>>>>> View the list's information and change your settings at
>>>>>>> //www.freelists.org/list/programmingblind
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Have a great day,
>>>>>> Alex (msg sent from GMail website)
>>>>>> mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
>>>>>> __________
>>>>>> View the list's information and change your settings at
>>>>>> //www.freelists.org/list/programmingblind
>>>>>>
>>>>>>
>>>>> __________
>>>>> View the list's information and change your settings at
>>>>> //www.freelists.org/list/programmingblind
>>>>>
>>>>
>>>> __________
>>>> View the list's information and change your settings at
>>>> //www.freelists.org/list/programmingblind
>>>>
>>>>
>>> __________
>>> View the list's information and change your settings at
>>> //www.freelists.org/list/programmingblind
>>>
>>
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind
>>
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: