6 Replies - 1837 Views - Last Post: 15 October 2012 - 11:11 PM

#1 edtwinfish  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-April 12

what classes, libraries, etc. to include in my code?

Posted 09 October 2012 - 07:13 PM

I'm focusing on C++ now, but have this question for any language. I know in C# you have to begin with
[using xyz]
or with C++ you have to start with
[#include <iostream>]

Otherwise certain things you use in your code, like the syntax to output to a printer will not know how to work. I have searched the internet for "how to find standard libraries", etc., but am not finding what I am looking for. Maybe I'm not sure how to ask the question, but...

If say I want to print to a printer and I find the syntax for my particular language, how do I know what library, class, header, etc. I need to include in order to use that syntax?

Also How can I look at the code in that library, class, etc. to see what is included in it?

Any clarification would really be helpful. It seems like it should be very easy to find my answer, but I'm just really confused on this and would love some help.

thank you!
:online2long:

Is This A Good Question/Topic? 0
  • +

Replies To: what classes, libraries, etc. to include in my code?

#2 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: what classes, libraries, etc. to include in my code?

Posted 09 October 2012 - 08:25 PM

Look for that language's API.

C++ API http://www.cplusplus.com/reference/
Java API http://docs.oracle.c...ase/6/docs/api/
.NET API http://msdn.microsof...y/gg145045.aspx

Found them all on Google. Some of them provide PDFs(heck, most of them should) and you can just download those.
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10647
  • View blog
  • Posts: 39,542
  • Joined: 27-December 08

Re: what classes, libraries, etc. to include in my code?

Posted 09 October 2012 - 08:33 PM

Moved to Software Development.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is online

  • member icon


Reputation: 4133
  • View blog
  • Posts: 12,869
  • Joined: 25-December 09

Re: what classes, libraries, etc. to include in my code?

Posted 09 October 2012 - 11:45 PM

Really the best way is to Google the function in question. For example to use cin in C++ Google "C++ cin" and unless the function is not standard you should have several links to show how to use this function in the first several links.

Jim
Was This Post Helpful? 1
  • +
  • -

#5 ccubed  Icon User is offline

  • It's That Guy
  • member icon

Reputation: 162
  • View blog
  • Posts: 1,407
  • Joined: 13-June 08

Re: what classes, libraries, etc. to include in my code?

Posted 14 October 2012 - 07:57 PM

C++ has using too. It allows you to use an entire namespace. It is a good practice however, I, and a couple of others, frown on it depending on conditions. Using can be a dangerous statement and increase program size in C++. I for one will only use it if I am making extensive use of multiple parts of a namespace. In that case, run time ends up being a little quicker so the extra space is a fair trade off. Other times though, I refuse to use it because I don't need the extra run time and don't use it enough to constitute the bloat.

If you mean the most common, my votes would be: iostream, cmath and the standard templates.
Was This Post Helpful? 0
  • +
  • -

#6 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: what classes, libraries, etc. to include in my code?

Posted 15 October 2012 - 07:35 PM

Quote

C++ has using too. It allows you to use an entire namespace.


No, that's not what using does. You can refer to symbols within a namespace using the scope resolution operator. What a using directive does is allow you to use those names without the qualifier.

Quote

Using can be a dangerous statement and increase program size in C++
How does affecting name lookup change the generated code?

Quote

In that case, run time ends up being a little quicker so the extra space is a fair trade off
Runtime and space. Interesting, given that using is purely compile time.

That's some really bad advice, born out of a scary lack of understanding...

This post has been edited by Oler1s: 15 October 2012 - 07:36 PM

Was This Post Helpful? 1
  • +
  • -

#7 ccubed  Icon User is offline

  • It's That Guy
  • member icon

Reputation: 162
  • View blog
  • Posts: 1,407
  • Joined: 13-June 08

Re: what classes, libraries, etc. to include in my code?

Posted 15 October 2012 - 11:11 PM

View PostOler1s, on 15 October 2012 - 08:35 PM, said:

Quote

C++ has using too. It allows you to use an entire namespace.


No, that's not what using does. You can refer to symbols within a namespace using the scope resolution operator. What a using directive does is allow you to use those names without the qualifier.

Quote

Using can be a dangerous statement and increase program size in C++
How does affecting name lookup change the generated code?

Quote

In that case, run time ends up being a little quicker so the extra space is a fair trade off
Runtime and space. Interesting, given that using is purely compile time.

That's some really bad advice, born out of a scary lack of understanding...


Not a lack of understanding. I don't know what I was doing when I wrote that. Let this be a good example of why you don't post to a coding forum when..out of it or something. Whatever the hell I was when I wrote this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1