• Advertisement

Archived

This topic is now archived and is closed to further replies.

PLEASE HELP, (C++ programming)

This topic is 5066 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

Well, I want to program in C++! I have Visual C++ 6.0 and want to learn how to make programs! I have read some tutorials but they only tell me how to make "Console" aplications! But I want to make programs for windows! Just "normal" programs, that wil not run in DOS or something! Anyway.. how do I start? I have Visual C++ 6.0 but I want to make my first program with it! I would like to buy s book...but I'm from the Netherlands... and there only a few books about C++! I'm very confused.. what does "GNU" means? And API or MFC (if I'm right)??? Is it nessacary to learn first how to make console aplications, and THAN start making "windows" aplications.. or can I just start with what I want (the windows programs ) Also I'm confused about the difference between C#, C and C++! I was reading a tutorial about C/C++, the tutorial was written for C, will I be able to use that tutorial for C++??? HELPPPPPP!!! I don't understand it anymore lol... [edited by - Toadhead on April 11, 2004 12:09:40 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Toadhead
Anyway.. how do I start? I have Visual C++ 6.0 but I want to make my first program with it! I would like to buy s book...but I''m from the Netherlands... and there only a few books about C++!
Hmm... I''m afraid I don''t know which good books will be available to you. Most of them are in English; how good are you at reading+understanding English?

quote:
I''m very confused.. what does "GNU" means? And API or MFS (if I''m right)???

GNU is more or less the collective name for a large group of programs which are ''open source'' - that is, the source code for them is available for you. You''re allowed to do what you want with it, but if you add features and stuff and then try putting it back out on the web, you''re forced to release the source as well (because of the license the code comes with).

API is ''Application Programming Interface,'' and refers to a set of functions, classes or structures which libraries (such as the Windows programming library, or the DirectX library) give to you for you to use to program applications with. For example, the Windows API contains a function called CreateWindow(), which you can call to have Windows create an on-screen window for you.

MFC is ''Microsoft Foundation Classes,'' and is a set of classes written by Microsoft designed to make Windows programming in C++ easier. Rather than working with the Windows API directly, you can use MFC, which makes many of the things you''d want to do automatic. The downside is that it''s quite hard to learn, and it''s usually not as fast as doing it through the Windows API directly.

quote:

Is it nessacary to learn first how to make console aplications, and THAN start making "windows" aplications.. or can I just start with what I want (the windows programs )
Depends on how well you know the language. The Windows API is significantly larger and more complicated than the stuff you''d use for console programs (probably just the standard library), and it''s harder to conduct simple experiments to try stuff out. Many people prefer to start out with console programs, because that way they don''t have to deal with learning the Windows API and the language at the same time.

quote:
Also I''m confused about the difference between C#, C and C++!
I was reading a tutorial about C/C++, the tutorial was written for C, will I be able to use that tutorial for C++???
C, C++, and C# are all similar languages, but they are different in their own ways. The tutorial will probably work, but there might be better ways of doing things that aren''t possible in C but are possible in C++.

Aside from all that, have you checked out the Beginner''s Resources section yet, along with the Forum FAQ?

Share this post


Link to post
Share on other sites
Its a good idea to start with console-applications to learn the basics of the language, win32 can be a bit tricky.

reality is only an option

Share this post


Link to post
Share on other sites
You have to learn all the basics of C++ by using a console window because apsects of Windows Programming uses things you learned about during console programming.

This is a good book: http://www.research.att.com/~bs/3rd.html
I like the online tutorial here too: http://www.cplusplus.com/doc/tutorial/

Use Google to look things up too. It's your best friend :D

GNU http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=define%3AGNU&btnG=Google+Search
API
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=define%3AAPI&btnG=Search

And I'll use the over used metaphor... You have to learn to craw before you walk.

- DarkNebula

[edited by - DarkNebula on April 11, 2004 12:14:43 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Toadhead
I have read some tutorials but they only tell me how to make "Console" aplications! But I want to make programs for windows!
Console programming is always promoted first because it allows you to focus on learning how to program without being inundated by the technical complexities of the Windows programming model and API. That said, a straight Windows program in Win32 isn''t hard. Here''s a pretty good tutorial: winprog.org.

quote:
what does "GNU" means?
It means, oddly enough, "GNU''s Not Unix." (Long story.) A gnu is an animal (here''s a picture).

quote:
And API or MFS (if I''m right)???
MFC. MFC stands for the Microsoft Foundation Classes, a set of object-oriented wrappers around the Win32 Application Programming Interface (API) for authoring Windows GUI (graphical user interface) programs in C++. They''re being phased out, along with the Win32 API, in favor of Windows Forms and the .NET SDK.

quote:
Is it nessacary to learn first how to make console aplications, and THAN start making "windows" aplications?
It''s not necessary, but it''s highly recommended. Windows can be rather confusing.

quote:
Also I''m confused about the difference between C#, C and C++!
Look it up on the web. Search Google (Netherlands version) or Wikipedia (again, Netherlands version) for "what is C#", "what is C++" and "what is C".

quote:
I was reading a tutorial about C/C++, the tutorial was written for C, will I be able to use that tutorial for C++?
C++ is largely backwards compatible with C, so you can compile most - but not all - C code with a C++ compiler.

Share this post


Link to post
Share on other sites
So in fact.. its recommandable to start with console aplications..

But ok.. when I start with programs like that.. is it easey to switch from consoles programs to "windows" programs?? I mean.. I''m affriad that I''m learning lots of things for console programs that will be totaly different when I want to make an windows program! I mean... isn''t it a complete different language???? For what I saw there is a big difference...


Yes.. I checked out the beginners ection abit but don''t realy found an answer to my question, maybe it is there but I can''t found it :/

Yes I also looked on Google but there only a few (if not no) tutorials for C++ in Dutch.. and only a few books, one over C# but I dunno if I can use that :/ and 1 or 2 other books that doesn''t sound that interesting and can''t realy help me I think :''(

And even if I would English books.. can I buy them in shops here? I don''t want to buy things online :/

Share this post


Link to post
Share on other sites
quote:
Original post by Toadhead
But ok.. when I start with programs like that.. is it easey to switch from consoles programs to "windows" programs?? I mean.. I''m affriad that I''m learning lots of things for console programs that will be totaly different when I want to make an windows program! I mean... isn''t it a complete different language???? For what I saw there is a big difference...
It''s the same language. Some of the functions will be different. You probably noticed WinMain for GUI vs main for console; that''s the accomodate the programming environment. The C++ standard allows you to replace the public entry point, but your new entry point must call the standard one (ie, WinMain internally calls a variant of main).

Don''t worry about it.

Can''t help you with books, particularly if you want local stores. Might I recommend going to a bookstore and asking the clerk?

Share this post


Link to post
Share on other sites
hm.. same language..

ok.. the main() and WinMain() is diferent.. but also the "#include <iostream.h>" and "#include <windows.h>", and things like cout>>"blabla"; and cinn<

Share this post


Link to post
Share on other sites
quote:
Original post by Toadhead
But ok.. when I start with programs like that.. is it easey to switch from consoles programs to "windows" programs?? I mean.. I''m affriad that I''m learning lots of things for console programs that will be totaly different when I want to make an windows program! I mean... isn''t it a complete different language???? For what I saw there is a big difference...


As Oluseyi has said, no, it''s the same language. The only thing that changes is the APIs you use, and even then you''ll usually find that you can use most of the standard library under Windows anyway. Think of it like this: it''s the same language with the same grammar and so on, but the vocabulary is going to be bigger. It''s the same as when you learn about something new in regular life; if you took up sailing as a hobby, for example, you''d find yourself learning a whole load of new words for parts of a ship and for its operating processes. Same thing here; you need to learn the "Windows jargon."

Share this post


Link to post
Share on other sites
ok, thanks everybody.. so the best is to learn the "Console" language first (the standerd C++ language), and when I understand that I must try to learn the "windows jargon".. :/

ok I will try it.. btw does anyone have a idea how long it wil take? How long do I need to spend into the normal C++ console language before I can program windows aplications? 6 months? 1 year? Or do I need to understand anything perfectly before I can start learning how to program/programming windows aplications?

[edited by - Toadhead on April 11, 2004 12:49:20 PM]

Share this post


Link to post
Share on other sites
"Console" is not a language

You can use many languages to program a console application, and you can generally use the same variety of languages to program GUI (graphical user interface) programs.

So in your case, you would want to spend several months playing with ''console applications'' using c++ and the standard library (probably also the template library). Then you may choose to move to win32 programs in the MS environment, which is when you would switch from using main() as your ''entry point'' to WinMain().

My personal opinion on time frames: you will find it easiest to learn ''the basics'' of c++ in console applications, so NEVER STOP PROGRAMMING IN THE CONSOLE. When you are feeling comfortable with the basics, you can try programming win32 apps, but whenever you are wondering about a specific thing, try it in console to test out your ideas, to establish good programming methods, etc etc.

win32 can be daunting on its own, so don''t be afraid to go back to console apps to try out your thoughts, and to write really strong classes for use by your win32 app.

Good luck.

Oh, and I also have on small favour to ask - could you refrain from over-punctuating every sentence? One question mark or one exclamation mark, used sparingly, is far more effective.

Share this post


Link to post
Share on other sites
quote:
Original post by Toadhead
btw does anyone have a idea how long it wil take? How long do I need to spend into the normal C++ console language before I can program windows aplications? 6 months? 1 year? Or do I need to understand anything perfectly before I can start learning how to program/programming windows aplications?


It depends on how quickly you learn your way around the language. If you''re a fast learner, it could only be a couple of weeks. My advice would be to set yourself a reasonably complex text-based target - for example, a text adventure game. If you can do that, then you''re ready to start playing around with Windows coding.

Share this post


Link to post
Share on other sites
lol..I'm not that far lol, Here's a program I just made:



#include <iostream.h>
int main()
{
int age;
cout<<"Please enter your age: ";
cin>>age;
if (age==1)
{
cout<<"So you are "; cout<<age; cout<<" year old? ";
}
else
{
cout<<"So you are "; cout<<age; cout<<" years old? ";
}
if(age==18)
{
cout<<"Ow.. so you're already an adult.\n\n";
}
else if(age<=18)

{
cout<<"Haha, I already thought you was just a child!\n\n";
}
else
{
cout<<"Jezus, you're old!\n\n";
}
return 0;
}





A tutorial is now trying to learn me how pointers work or sometihng..but I don't understand it :'( Anyone who can tech it to me lol







And about "could you refrain from over-punctuating every sentence"...sorry, but thats just me lol, there like 10 others that told me why I'm doing that, I dunno..I just can't stop doing that Every time when I'm playing under another name in the same 2D MMORPG, they know its me just becuase how I typ

[edited by - Toadhead on April 11, 2004 3:27:26 PM]

Share this post


Link to post
Share on other sites
Okay, I''d avoid pointers for the moment. Keep working with condition statments (if-then-else and switch), learn looping (for, do...while) and then, once you''ve got a good grasp on those, look into arrays (and STL containers, namely the ''vector'' container). Those are all fundamental to any kind of programming. Good luck

Share this post


Link to post
Share on other sites
I just learned how things like !(0 || 1) and (1 && 0) work lol

|| means OR
&& means AND
! means NOT

Only I dunno how to put them into an piece of code :/
They haven''t made an example of it :''(

The next part of the tutorials is about loops, I will learn that tomorrow.. I decided to start programming today, and learned all of this today, I think thats all enough for one day, loops will come tomorrow lol





Share this post


Link to post
Share on other sites
Seems like a good plan, don''t fry your brain For your reference, I''ll give you a couple of examples of those operators

// do this if the first AND the second condition both met
if (age > 29 && age < 60)
{
cout << "You are middle aged";
}

// do this if either the first OR the second condition is met
if (age < 17 || age > 45)
{
cout << "You can''t join the army";
}

// one of the more common uses of ! is in !=, which means
// not equal to. for example:

if (age != 18)
{
cout << "You are not 18 years old";
}

There are other uses for !, but don''t worry about them until you get a better grasp on the language. Hope that clears those up a bit for ya!

Share this post


Link to post
Share on other sites
quote:
Original post by Toadhead
#include <iostream.h>



Don''t do that. iostream.h is the old, just-after-C++-was-invented name for the header; the name you *should* be using is just <iostream>.

Share this post


Link to post
Share on other sites
Thanks for the examples Instruo!
Ow.. and thanks superpig for your imformation about iostream.. next time I will use

Share this post


Link to post
Share on other sites
superpig.... doesn't work!!! I must use iostream.h

[edited by - Toadhead on April 12, 2004 4:05:33 AM]

Share this post


Link to post
Share on other sites
MAN! I hate C++

Whats wrong with the following code:




#include <iostream.h>
int main()
{
int age;
cout<<"Please enter your age: ";
cin>>age;
cout<<"So you are " <<age <<" years old? ";

if(age > 18 && age < 25)
{
cout<<"You are between the 18-25 years old!\n\n";
}


if else(age == 5 || age == 10);
{
cout<<"You are 5 OR 10 years old!\n\n";
}

else

{

cout<<"You are not 5, 10 or 18-25 years old!\n\n";

}

return 0;
}




I got 2 errors:

Compiling...
Toadhead.cpp
line(15) : error C2059: syntax error : 'else'
line(20) : error C2181: illegal else without matching if
Error executing cl.exe.

Toadhead.exe - 2 error(s), 0 warning(s)


[edited by - Toadhead on April 12, 2004 4:00:16 AM]

Share this post


Link to post
Share on other sites
< iostream > will work fine, as long as you put in the following code right below the #include:
using namespace std;

That should work.



[edited by - Drevay on April 12, 2004 4:38:37 AM]

Share this post


Link to post
Share on other sites
??? why should I use that?????????????????????
It's easier to just use iostream.h instead of iostream using namespce ntd. or whatever it is!

[edited by - Toadhead on April 12, 2004 4:46:20 AM]

Share this post


Link to post
Share on other sites
iostream.h is deprecated and bad style.

Edit: And one "?" is enough to mark a question.

[edited by - BitMaster on April 12, 2004 5:27:11 AM]

Share this post


Link to post
Share on other sites

  • Advertisement