The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C / C++


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 07-13-2007, 03:20 PM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Learning C++

Hey,

I have always wanted to learn C++ and im up for learning some more, i know the basics with console app's, i can use variables, input/output etc, i know how to do some of the mathematical sums, i would have to do more though i think, my ultimate aim is to get into windowed applications and directx etc.

Question is what do i need to learn to get there? i was hoping the few people around now that know C++ could help me out, maybe with a list of things such as variables, mathematical sums etc? and in an order would help me a lot because i would love to progress other things maybe file handling etc, also would i have to learn them in a console app before i move onto windowed app's?

hope i have not muddled up all the words to much lol.
Thanks for any help.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 07-13-2007, 03:24 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
sorry man, I can't help you out with C++ XD
I'm also planning to learn C++ though, in the future probably once i'm set with ASP.NET

As probably I post on the other thread, I just know

Code:
cout << "Hello World" << cin;

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 07-13-2007, 08:31 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
Regarding Windows programming, I recommend theForger's Win32 API Tutorial unless you wish to use MFC (Visual C++ only as far as I know). Of course, there are also Windows Forms now with the .NET platform, so that may also be an option. Personally, the Win32 API made me wonder why it is so complex. There is an event handler for EVERYTHING. A simple text editor can be difficult for a Win32 API beginner using just the Win32 API. As for MFC and Windows Forms, I have no experience with either of them, though I plan to look into MFC possibly.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to rpgfan3233 For This Useful Post:
Lee (07-14-2007)
  #4 (permalink)  
Old 07-13-2007, 11:44 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Win32 API
I'm a little bit confused when you say about this API, isn't Windows programming are all using .NET Library? Are there more than one API provided for C++ ??? Sorry, I'm a Java programmer, and there's only one API that we use from Sun...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 07-14-2007, 05:42 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Quote:
Originally Posted by rpgfan3233 View Post
Regarding Windows programming, I recommend theForger's Win32 API Tutorial unless you wish to use MFC (Visual C++ only as far as I know). Of course, there are also Windows Forms now with the .NET platform, so that may also be an option. Personally, the Win32 API made me wonder why it is so complex. There is an event handler for EVERYTHING. A simple text editor can be difficult for a Win32 API beginner using just the Win32 API. As for MFC and Windows Forms, I have no experience with either of them, though I plan to look into MFC possibly.
Thanks, i will not be looking at the .NET section for this sort of thing, i would like to learn all about C++ and then in the future i can maybe move onto directx with C++ and other things as finding directx tutorials for VB.NET 2005 can be hard work.

I was hoping you could maybe make a list for me and other beginners looking, things i can think of to start:

1. Hello World Program
2. Variables
3. Using input & variables e.g. cin
4. Simple mathmatical operators.
5...??

Maybe you could continue it a little bit, it would help me greatly

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 07-14-2007, 08:14 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Well, I personally say that I don't really care with the really basic ones, since you can also find it everywhere lol... I personally want to see conscepts (rules in C / C++) and little more advanced such as: Multidimentional Arrays, Arrays, Recursive Methods, .....

BTW, does C++ has the same types of variable that can store the same size in memory as Java? (I'm not positive at this since Java is much higher level language than C++)

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #7 (permalink)  
Old 07-14-2007, 08:30 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Quote:
Originally Posted by HelloWorld View Post
Well, I personally say that I don't really care with the really basic ones, since you can also find it everywhere lol... I personally want to see conscepts (rules in C / C++) and little more advanced such as: Multidimentional Arrays, Arrays, Recursive Methods, .....

BTW, does C++ has the same types of variable that can store the same size in memory as Java? (I'm not positive at this since Java is much higher level language than C++)
Reason i am asking is because with a language like C++ it helps to know all the basics as it gives you a much bigger understanding for the harder things which then helps you progress much quicker than jumping the gun a bit.

I cant really help with your question as i am not familiar with Java, YET ... On my list of things to learn in the next 5 years lol.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #8 (permalink)  
Old 07-14-2007, 08:58 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
Quote:
Originally Posted by HelloWorld View Post
Well, I personally say that I don't really care with the really basic ones, since you can also find it everywhere lol... I personally want to see conscepts (rules in C / C++) and little more advanced such as: Multidimentional Arrays, Arrays, Recursive Methods, .....
Perhaps I might write one sometime.

Quote:
Originally Posted by HelloWorld View Post
BTW, does C++ has the same types of variable that can store the same size in memory as Java? (I'm not positive at this since Java is much higher level language than C++)
----
variable types compared: C++ v.s. Java
Quick note: Java only has signed data types

bool[1] = boolean - 1-byte (8-bit) type that utilizes true/false values

char = byte - 1-byte (8-bit) type that allows you to use characters/values 0-255 (-128 to 127 when using signed values)

short[2] (int) = short - 2-byte (16-bit) integer type that allows you to use integer values in the range 0x8000-0x7FFF (-32768 to 32767 (signed), 0 to 65535 (unsigned))

long[2] (int) = int - 4-byte (32-bit) integer type that allows you to use integer values in the range 0x80000000-0x7FFFFFFF (-2,147,483,648 to 2,147,483,647 (signed), 0 to 4,294,967,295 (unsigned))

long long[3] (int) = long - 8-byte (64-bit) integer type that allows you to use integer values in the range 0x8000000000000000-0x7FFFFFFFFFFFFFF (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed), 0 to 18,446,744,073,709,551,615 (unsigned))


[1] - bool in C++ is technically just an integer type that allows you to use keywords "true" and "false". In Java when you output a boolean value, the result is either True or False. In C++, the respective output is 1 (True) or 0 (False). Also, the Java boolean data type isn't precisely defined as 1 byte in size. It only takes up 1 bit (0 or 1), but the least amount of bits you can operate on is 8 bits (1 byte).

[2] - In C++, the value of the int type depends on whether it is equivalent to the short int type or the long int type. The way to test is by using std::cout << ((sizeof(int) == sizeof(long)) ? "true" : "false") << std::endl;

[3] - long long (int) is not officially an ISO C++ data type. However, it is most probably going to be present in C++0x when the standard is published. It is present in many compilers to remain compatible with C99, which adds signed long long and unsigned long long to its list of primitive data types (char, short, int, long, etc.)
----

The closest equivalent of the Java char data type (a 16-bit Unicode character) in C++ is known as wchar_t (wide-character type), which is declared in wchar.h (it is not a primitive data type). It may behave the same, but I'm not sure if it does or not since I have little experience with wchar_t.



Edit 1:
Quote:
Originally Posted by HelloWorld View Post
I'm a little bit confused when you say about this API, isn't Windows programming are all using .NET Library? Are there more than one API provided for C++ ??? Sorry, I'm a Java programmer, and there's only one API that we use from Sun...
There are many APIs for C++, such as wxWidgets (similar to the style of Java Swing from what I've seen), Qt, GTK+, Win32, DirectX and more. The definition of "API" isn't limited to just programming windowed applications, or GUIs as they are better known (Swing and AWT are the APIs for GUI programming in Java).

As for the APIs used in Windows, you can use the Win32 API, which uses an event-driven model. This is as close to Windows as you can get. You can use MFC, which is a form of the Win32 API for C++ programming (much cleaner using MFC than normal Win32 programming). There is also the .NET framework, which allows you to use Windows Forms. It is simply another way to code the same thing, except this one is purely for .NET rather than for C or C++ or whatever. C# uses it, just like VB.NET, VC++.NET and J# use it because they are all a part of the .NET family.

Edit 2:
As for a specific API for C++, there are some that exist, such as wxWidgets, but any API that can be used with C can almost certainly be used with C++. However, APIs for only C++ cannot be used with C because C is almost 100% compatible with C++, but C++ is less than 20% compatible (I'm guessing) with C because of the features that C++ uses, not to mention the extremely strong type checking in C++ whereas C is fairly relaxed. However, I don't think you can quite mix APIs for GUI programming in very many languages other than Java (you can mix AWT and Swing somewhat).

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by rpgfan3233 : 07-14-2007 at 09:13 PM. Reason: Answered another question and hopefully clarified some things.
Reply With Quote
The Following User Says Thank You to rpgfan3233 For This Useful Post:
HelloWorld (07-14-2007)
  #9 (permalink)  
Old 07-14-2007, 10:24 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
bool in C++ is technically just an integer type that allows you to use keywords "true" and "false".
Is this one way I can declare boolean in C++?

Code:
int wrong = false
This is WEIRD!!! why?? Is that because computer just read 1 and 0? (since 1 and 0 are integers..)

Edit:
Please give me some example C++ variable writing and the way you reference them?

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #10 (permalink)  
Old 07-14-2007, 10:54 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
Quote:
Originally Posted by HelloWorld View Post
Is this one way I can declare boolean in C++?

Code:
int wrong = false
This is WEIRD!!! why?? Is that because computer just read 1 and 0? (since 1 and 0 are integers..)
As far as I know, yes a boolean value in C++ is simply a special integer. You can easily simulate boolean values using the following in C:
Code:
typedef enum { false = 0, true = !false } bool;
All that does is just create an anonymous enum (enumerated list of values) and then give it a type name called "bool". I'm sure this is similar how it is done on many C++ compilers, especially since Visual C++ 6.0 and gcc-4.1.2 didn't warn me about doing "int wrong = false;".

Quote:
Originally Posted by HelloWorld View Post
Edit:
Please give me some example C++ variable writing and the way you reference them?
C++ variables are declared in the same way that variables in Java and C#:
Code:
int x = 2; //valid code in C, C++, Java and C#

// uncomment the one that you want
// std::cout << x << std::endl; //C++ - remember to include <iostream>
// System.out.println(x); //Java
// System.Console.WriteLine(x); //valid C# I think
// printf("%d\n", x); //C - remember to include <stdio.h>
I'm not sure what you meant by "reference", but I hope that code gives you a better idea.


Edit:
Visual C++ 6.0 gave me a warning when I tried to assign 2 to "bool right". It truncated the value from a "const int" ("final int" in Java, I think?) to a non-zero value (1), which is considered true. However, that was only a WARNING, not an ERROR. In other words, any non-zero value is true. However, for integer types and character types other than bool, one shouldn't get into the habit of something like:
Code:
while (!feof(myfile)) { //while the file pointer hasn't reached the end of the file, execute code
    //code
}
That was C code. It is understood that a non-zero value is taken to be true and a zero value is equivalent to false. Despite the convenient idea, it is bad coding style since the return type of "feof" is an integer, not a boolean value like "1 > 0" would return (even if it is just an integer, it is still different from a normal integer). Instead, as long as a function's return value isn't boolean, one should ALWAYS use something like this:
Code:
while (feof(myfile) != 0) { //while the file pointer hasn't reached the end of the file, execute code
    // code
}
Things like the following are also quite common:
Code:
x = (n <= 0); //if n is less than or equal to 0, then x = 1, otherwise x = 0
The reason for such things is due to the nature of wanting to check whether a specific statement is true/false and the lack of a boolean type in C. Simply put, C++ added a boolean type due to the fact that the only other way to represent it was to use char because bool needed to be small (it only requires 1 bit... :p) and the smallest data type is char, which seems unsuitable since the integer 0 certainly isn't a character really, even though char is pretty much just a 1-byte (8-bit) integer data type. One can typecast a char to an int value to get the character code. This is why char and int are often regarded as interchangeable.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by rpgfan3233 : 07-14-2007 at 11:13 PM. Reason: Added some information...
Reply With Quote
The Following User Says Thank You to rpgfan3233 For This Useful Post:
HelloWorld (07-21-2007)
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 10:40 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50