Jump to content
  • Advertisement
Sign in to follow this  
Spirytus

begginner c++ questions

This topic is 4953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi :) i've always wanted to get more familiar with c++ but cause of lack of the time never really had a chance until now. im quite familiar with java and all oo concepts and so far thx to this board i found (in my opinion) very good book "c++ in 21 days" (or similar title) and lots of tutorials on the c++ subject. however i've still got lots of questions and i hope some of you guys will be able to help me: 1. i found tutorials on creating windows and standard gui elements but it dosent seem very easy and i was wonder how it is done in real life. do the real programmers working in real comanies know how to hand code all that stuff or they have no knowledge ofit at all and simply using drag&drop? 2. what is the deal with all those libraries that are included at the beggining of the file with #include directive? who provides them, and if for ex. windows.h is standard library used with windows or it depends on ide used? i'm using dev-C++ for now and it has got all those .h files provided but with for ex. visual studio would those .h files be different? 3. i'm getting confused with code below (i hope i spelled it correctly) int WINAPI winMain(....){.. i understand that winMain is simply used instead of main() for windows programs, but whatthe heck is WINAPI? i guess winMain returns integer but tutorials i've read dont expalin what WINAPI is and only says that it has to be there. 4. is there any documentation similar to API documentation provided by sun for java? it would be very usefull. i've got lots more questions to ask and surely will be posting more very soon but for now i'd appreciate if someone could answer my questions or point me to resources where questions above would be ansswered. btw i have honestly searched thru forums and googled in search for answers with no luck so this forum and u guys is my last hope ;) thx in advance for any help

Share this post


Link to post
Share on other sites
Advertisement
Most people don't work with directly with the Win32 API directly anymore. There are numerous higher-level (OO) frameworks for implementing a GUI. You might want to familiarize yourself with standard (pure?) C++ first.

Quote:
4. is there any documentation similar to API documentation provided by sun for java? it would be very usefull.

MSDN Library.

Here are two more resources worth purusing:
Bjarne Stroustrup's C++ page
SGI's STL Manual

Share this post


Link to post
Share on other sites
First off, good luck.

Now, to some answers. [and as always, I am not an expert, so some of this might be slightly inaccurate]

1: I don't know for sure, but I'd wager that they use their own, or someone else's premade code to handle all of the 'difficult' parts, reducing the code to "make_window(coords, style, "Window Name")" or some such.

For my GUI work in DirectX, I have premade classes that do a lot of the stuff behind the scenes. Initially making them was tedious and challenging, but now using them is fairly easy.

2: Depends on the library. If you're programming on windows, with Visual Studio, they're pretty much all provided by Microsoft as part of visual studio. Most of them [if not all] were probably written by microsoft as well.

If you're not using Visual Studio, then the library can be written and/or maintained by anyone. Generally this info is in the actual header file if you're curious.

Yes, the actual header file names are fairly standardized. Different unix platforms might have them in different places [sys/types.h rather than just types.h for example] but generally things are pretty similar.

3: WINAPI is a calling convention. You can pretty much disregard its meaning, but understand that it's required. If you're still curious, it's essentially a compiler directive to change how the function is made into its part of the executable so that the OS can deal with it.

4: [edit: oops, you meant like java's doc site, rather than java's doc site...] MSDN is perhaps the closest, though that will contain microsoft specific stuff as well as the C++ standard.

Share this post


Link to post
Share on other sites
Quote:

1. i found tutorials on creating windows and standard gui elements but it dosent seem very easy and i was wonder how it is done in real life. do the real programmers working in real comanies know how to hand code all that stuff or they have no knowledge ofit at all and simply using drag&drop?


After you have written several applications using any API you will start to remember bits of it by heart. Much more important is knowing where to look up the parameters to a function you need. Im a "real" programmer and I, and all the programmers I work with, consult documentation frquently. This is a concern that a lot of new programmers have, but really dont worry about it.

Quote:

2. what is the deal with all those libraries that are included at the beggining of the file with #include directive? who provides them, and if for ex. windows.h is standard library used with windows or it depends on ide used? i'm using dev-C++ for now and it has got all those .h files provided but with for ex. visual studio would those .h files be different?


Different header files come from different places. Things like iostream, fstream are part of the standard library which every compiler should have available. windows.h is part of the windows API which most windows based compilers will provide (or you can download the windows sdk from msdn to get it and all the other header/library files for windows development).


Quote:

3. i'm getting confused with code below (i hope i spelled it correctly)

int WINAPI winMain(....){..


WINAPI is a calling convention. Basically there are a couple of different ways that when you code is running it can call functions. By putting the WINAPI there you are telling the compiler explicitly what convention this function will be called with. A google search for the phrase "calling conventions" will turn up tons of information.

Quote:

4. is there any documentation similar to API documentation provided by sun for java? it would be very usefull.


I assume you mean documentation for the windows API? If so, your best refernce is msdn.

Quote:

i've got lots more questions to ask and surely will be posting more very soon but for now i'd appreciate if someone could answer my questions or point me to resources where questions above would be ansswered.

btw i have honestly searched thru forums and googled in search for answers with no luck so this forum and u guys is my last hope ;) thx in advance for any help


Cool. As long as you make the effort yourself first, people are always happy to help out answering questions.

Alan

Share this post


Link to post
Share on other sites
Most programmers know how to program. The people that design the guis for applications use a lot of drag and drop (have you looked at VB?) because they do a lot of the same thing, over and over again. Sort of like writing a function to make something easier. Game programmers, on the other hand, would probably do the majority of the gui from scratch from game to game, always striving for the best.

If you look in the header files, WINAPI is just a define for __stdcall. Its like telling the os you have a function that is standardized, that it can call, or other such things. If using this, you wouldn't need the include of windows.h. It is not the return type, just a different programming...thing. Can't figure out a good word for it right now. It's like how you can write extern before declaring a variable...just changes how things are done.

About the different headers (such as windows.h), each compiler will have its own versions. They are essentially the same, but for instance a microsoft one will use some non-iso programming conventions that only work on a microsoft compiler. They are being provided by the compiler-maker, but a lot of them are standardized now. if you ever see one without an extention (like #include <iostream>), that follows the iso standard, so should probably work on any compiler, others, not guarenteed (or even likely). If you feel like it, you could make your own library of headers, and use that instead.

Make sense?

Share this post


Link to post
Share on other sites
You should use a framework such as VC++ MFC library. Just to create even a simple windows application may look difficult and complicated, but using such libraries you don't have to worry about winMain() etc... Just write the code for want your program really have to do.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!