C++ FAQ's for complete Beginner

Discussion in 'C++' started by Putnam, Feb 14, 2010.

  1. Putnam

    Putnam New Member

    Joined:
    Feb 13, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Dairy Queen Worker
    Home Page:
    http://rstips.net/index.php

    C++ FAQ's



    I've spent the past few weeks learning C++, and here are a bunch of FAQ's I came up with. Some of these Q n A's are from various sources, but I have edited and revised them using my own words.

    What is C++?

    C++ is a computer programming language. Its name is literally 'increased C' reflecting its nature as an evolution of the C language.


    Is it Necessary to Know Any Other Programming Languages Before C++?

    Absolutely Not. C++ is a simple and clear language in its expressions. It is true that a piece of code written with C++ may be seen by a stranger of programming a bit more cryptic than some other languages due to the intensive use of special characters ({}[]*&!|...), but once you know the meaning of such characters it can be even more schematic and clear than other languages that rely more on English words.
    Also, the simplification of the input/output interface of C++ in comparison to C and the incorporation of the standard template library in the language, makes the communication and manipulation of data in a program written in C++ as simple as in other languages, without losing the power it offers.

    How can I learn C++?

    There are many ways. Depending on the time you have and your preferences. Although you can go to fancy computer science schools to learn this language, the most popular way of learning is through trial and error. I would recommend you pick up a book at a book store, such as Barnes and Noble.

    What is OOP: Object-oriented programming?

    It is a programming model that treats programming from a perspective where each component is considered an object, with its own properties and methods, replacing or complementing structured programming paradigm, where the focus was on procedures and parameters. Sorry for the paragraph long run-on sentence.

    What is ANSI-C++?

    ANSI-C++ is the name by which the international ANSI/ISO standard for the C++ language is known. But before this standard was published, C++ was already widely used and therefore there is a lot of code out there written in pre-standard C++. Referring to ANSI-C++ explicitly differentiate it from pre-standard C++ code, which is incompatible in some ways.

    What is Visual C++? And what does "visual programming" mean?

    Visual C++ is the name of a C++ compiler with an integrated environment from Microsoft. It includes special tools that simplify the development of large applications as well as specific libraries that improve productivity. The use of these tools is generally known as visual programming. Other manufacturers also develop these types of tools and libraries, like Borland C++, Visual Age, etc...

    Is C++ a practical language?

    Yes.

    C++ is a practical tool. It's not perfect, but it's useful.

    Is it a Perfect Language?

    No.

    C++ wasn't designed to demonstrate what a perfect Object-Oriented language looks like. It was designed to be a practical tool for solving real world problems. It has a few bugs, but the only place where it's appropriate to keep fiddling with something until it's perfect is in an academic setting. This isn't C++'s goal.

    What's the big deal with OOP?

    Object-oriented techniques currently are the best way to develop large, complex software applications and systems.

    C++ is an OO programming language. C++ can also be used as a traditional programming language (as "as a better C"). However if you use it 'as a better C,' don't expect to get the benefits of object-oriented programming. :p

    What is a class?

    A class is the fundamental building block of OO software.

    A class defines a data type, much like a struct would be in C. In a computer science sense, a type consists of both a set of states and a set of operations which transition between those states. Thus int is a type because it has both a set of states and it has operations like i + j or i++, etc. In exactly the same way, a class provides a set of (usually public:) operations, and a set of (usually non-public:) data bits representing the abstract values that instances of the type can have.

    What is an object?

    A region of storage with associated semantics.

    After the declaration int i; we say that "i is an object of type int." In OO/C++, "object" usually means "an instance of a class." Thus a class defines the behavior of possibly many objects.

    What is a reference?

    An alias (an alternate name) for an object.

    References are frequently used for pass-by-reference:
    Code:
    void swap(int& i, int& j)
        {
          int tmp = i;
          i = j;
          j = tmp;
        }
        
        int main()
        {
          int x, y;
          // ...
          swap(x,y);
        }
    Here i and j are aliases for main's x and y respectively. In other words, i is x — not a pointer to x, nor a copy of x, but x itself. Anything you do to i gets done to x, and vice versa.

    OK. That's how you should think of references as a programmer. Now, at the risk of confusing you by giving you a different perspective, here's how references are implemented. Underneath it all, a reference i to object x is typically the machine address of the object x. But when the programmer says i++, the compiler generates code that increments x. In particular, the address bits that the compiler uses to find x are not changed. A C programmer will think of this as if you used the C style pass-by-pointer, with the syntactic variant of (1) moving the & from the caller into the callee, and (2) eliminating the *s. In other words, a C programmer will think of i as a macro for (*p), where p is a pointer to x (e.g., the compiler automatically dereferences the underlying pointer; i++ is changed to (*p)++; i = 7 is automatically changed to *p = 7).

    Important note: Even though a reference is often implemented using an address in the underlying assembly language, please do not think of a reference as a funny looking pointer to an object. A reference is the object. It is not a pointer to the object, nor a copy of the object. It is the object.

    That's All For Now!



    If you want to view the full article, not just 1/4 of it, please visit rstips.net
    I'm sure if you search around, you can find this article.


    Thank You!,
    Putnam
     
  2. hanleyhansen

    hanleyhansen New Member

    Joined:
    Jan 24, 2008
    Messages:
    336
    Likes Received:
    8
    Trophy Points:
    0
    Occupation:
    Drupal Developer/LAMP Developer
    Location:
    Clifton
    Home Page:
    http://www.hanseninfotech.com
    This is good info but I think it's a little beyond a complete beginner. There's some vocabulary in there that a complete newbie to computer science wouldn't understand. Other than that it is very good info that is simply put.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice