Thread: Hello ,about program.

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    Hello ,about program.

    Hello,

    I have some questions about programming in C++,

    I am new to programming and making a program about prime numbers, and need your help.

    Q.1Does standard library file already exists in Dev C++ program?

    Q.2 If we make a link list data structure, do we have to make a node.cpp file? Is this node.cpp file already their in the library of the Dev C++?

    thanks,

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    1. Yes, if you have installed it correctly. The standard library is header only though (afaik).
    2. If YOU make a library, how can it be in the library already ?
    Make your node.cpp and node.h.
    Make sure to have node.cpp included (in the project?) when compiling your main file.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    If you're using Dev C++ you should update the compiler that it uses. The one it comes with is pretty ancient.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    Ok thanks for the reply,

    So it means that node.cpp file is not included in the C++ library ,do I have to make it ?

    Is it an implementation file?

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    So it means that node.cpp file is not included in the C++ library ,do I have to make it ?

    Is it an implementation file?
    Obviously: as manasij7479 guessed, node.cpp is presumably your own source file, so it is not included in the standard library.

    If you do want to use standard library facilities for linked lists, then #include <list> and use std::list.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    laser light,

    Thanks for your reply,

    So if we use standard library eg. <list> for linked lists, and use std:list, is this an implementation file or the interface file?

    Thanks

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    So if we use standard library eg. <list> for linked lists, and use std:list, is this an implementation file or the interface file?
    <list> is a standard header. Typically, a standard header is actually a header file, though this is not required. A standard header certainly allows you to use the interface of the associated standard library component(s), but it may or may not contain implementation.

    Anyway, the C++ standard does not mandate any particular implementation, so you do not need to be concerned with the implementation of the standard library if you just want to use a library component.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    thanks for the reply,

    so if we just use the interface methods of link list, or any other data structure in C++ program, then we don't need to include any .cpp file?

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    so if we just use the interface methods of link list, or any other data structure in C++ program, then we don't need to include any .cpp file?
    If you mean "include" as in a #include, then yes. In fact, it is very rare to include a source file in any C++ program: you might only do so if the source file is not meant to be compiled on its own, but rather is included in a header as a special approach to implementing function templates (but then it would not be recommended to use .cpp as the file extension as it can be confusing). At the moment, you probably don't need to worry about this, so just take it that any time you include a source file, you're doing it wrong.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-11-2012, 12:25 AM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  4. Replies: 18
    Last Post: 11-13-2006, 01:11 PM
  5. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 11:53 AM