Results 1 to 5 of 5

Thread: C++ Programming

  1. #1
    Join Date
    Oct 2013
    Beans
    336
    Distro
    Xubuntu 14.10 Utopic Unicorn

    C++ Programming

    Ubuntu Studio 14.10

    I want to start programming in C++. I already use C, Java, and Bash.

    I absolutely hate IDEs, so please don't suggest them. I want to write code in a text editor like Gedit, and compile through command line tools.

    What do I need to install?



    Edit:

    I installed g++, but when I go to compile any program, I get errors like "‘cout’ was not declared in this scope"
    Last edited by Tristan_Williams; March 5th, 2015 at 12:29 AM.
    Things to remember :
    - Use proper english
    - Comment your code
    - Keep background information and introductions to a minimum

  2. #2
    Join Date
    Jan 2009
    Location
    South Carolina
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: C++ Programming

    I'd start by installing the build-essential metapackage, which will install gcc and g++ for compiling C and C++ code, respectively.

    I personally recommend vim as a text editor, but that's just me. Gedit is also available, as well as plenty of other text editors that you can try out and find one that suits your needs.

    Edit: Your error "'cout' was not declared in this scope" is an error in your code, most likely not including the iostream library.

  3. #3
    Join Date
    Jul 2008
    Location
    The Left Coast of the USA
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: C++ Programming

    Moved to Programming Talk.

    As a professional software developer, I couldn't do what I do and meet deadlines without an IDE. Just sayin'.
    Please read The Forum Rules and The Forum Posting Guidelines

    A thing discovered and kept to oneself must be discovered time and again by others. A thing discovered and shared with others need be discovered only the once.
    This universe is crazy. I'm going back to my own.

  4. #4
    Join Date
    Oct 2014
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: C++ Programming

    Before go any further, can you answer these simple questions?

    1. How long have you been programming in C, Java or scripting Bash?

    2. Do you make any useful programs or involved in any project in development (in this case - programming)

    3. Which type programmer you are? Casual programmer, hobbyist programmer, professional programmer?

    cout error is probably because of -

    1. You don't include header library - iostream (for input/output stream)

    2. You don't declare the use of the method/class in iostream - using namespace std / std::cout

    If you wanna compile a simple example, here it is

    Code:
    /* hello.cpp -- This print "Hello, World!" string. */
    
    #include <iostream> // This include input/output stream header library, if you programming in C, it's just a bit same with <stdio.h>
    using namespace std; // This declare of using standard method in <iostream>, you will understand better in OO's lesson.
    
    int main()                // Program start here
    {
        cout << "Hello, World!" << endl;    // cout mean print and endl mean 'endline', endl is same with '\n' in C.
        return 0;                                     // This terminate the program and return 0 to OS
    }                                                   // This end the block of int main
    compile this with this command

    Code:
     make hello.cpp
    I'm using vim as my text editor, it's very easy to use and fun.
    Last edited by flaymond; March 9th, 2015 at 01:37 PM.

  5. #5
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: C++ Programming

    Quote Originally Posted by QIII View Post
    Moved to Programming Talk.

    As a professional software developer, I couldn't do what I do and meet deadlines without an IDE. Just sayin'.
    So do I. And IDE isn't just something that compiles the code for you. It's also something that keeps track of everything. You click a method usage and it shows you where this method comes from in your hierarchy. It can suggest valid completions because it knows what makes sense where you are. When something is badly named you can rename it and it will fix the rest of the code to match. If you work with several other people there are parts of the code you barely know, but the IDE will know them. Pre-Y2K IDEs where an impairment to the good programmers, but they have come a long way...
    Warning: unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •