C++ FAQ's for complete Beginner

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

  1. Putnam

    Putnam New Member

    Feb 13, 2010
    Likes Received:
    Trophy Points:
    Dairy Queen Worker
    Home Page:

    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?


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

    Is it a Perfect Language?


    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:
    void swap(int& i, int& j)
          int tmp = i;
          i = j;
          j = tmp;
        int main()
          int 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!,
  2. hanleyhansen

    hanleyhansen New Member

    Jan 24, 2008
    Likes Received:
    Trophy Points:
    Drupal Developer/LAMP Developer
    Home Page:
    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

    Jul 12, 2004
    Likes Received:
    Trophy Points:

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