[Current Forum ] [Archive 2003 - 2005]
[Register]  [Profile]  [Preferences]  [Search]
[Private messages]  [Memberslist]  [FAQ]  [Login]
Subsim Radio Room Forum Index » » Indie Subsims » » C++
Goto page ( Previous Page 1 | 2 | 3 Next Page )
Author C++
DaleW


Joined: May 18, 2002
Posts: 37
Posted: 2002-10-09 16:49   
Quote:

On 2002-10-09 15:35, Tinfish wrote:
So could someone tell me the difference between C and C++?



++
_________________


  View Profile of DaleW      Edit/Delete This Post   Reply with quote
Deamon


Joined: May 10, 2002
Posts: 620
From: Germany
Posted: 2002-10-09 17:10   
Quote:

On 2002-10-09 15:35, Tinfish wrote:
So could someone tell me the difference between C and C++?



C++ can be seen as a very big and mighty extension of C.C is a language that is strictly object oriented and allows you great freedom and versatility.C encapsule the code mainly in funktions(i assume you konw what i mean).C++ goes even mutch further and enfolde the whole potential of object oriented programming by entroducing classe whitch contains the functions in this case called methods,Heritage,class hyrarchie,polymorphismus etz. C++ allows a mutch better structuration of the code architecture and can save you lots of work compared to C.C was a revolution and C++ is the second revolution.C is compared to C++ rather a simply and comfortable language that only have 32 keywords but gives you a maximum of possibilitys with them.C is also a language that is closer to the Hardware it even allows bit operations on assembler level.C++ is also called C with classes.Classes are really the next higher level of object oriented programming(and therefore mutch more difficult to understand).C++ contains most parts of C as sub amount but extends the functionality of them greatly and additionaly the stuff mentioned above.For example C++ have 73 Key words.As far as i know it's also more secure then C.

Even C can be hard to learn at the beginning(and mostly it is so) couse it's a very closed in it's self language.C++ is evidently mutch harder to learn not just it has more funktions but it's on a mutch abstracter level then C.But once the object orientation concept is understood then it's mutch more easier.

But if you already have programming experiance then you should understand it mutch faster then i did.I hadn't programming experiance as i started with C so it was preatty hard,also due to a leak of good books.It's essential to have a few very good books.The best books are in english,a far as i know.

So it's a preatty good idea to start with C as a stand allone language.

I hope that was acceptable explenation.Mybe Manuell can explain it better.

_________________


IMPERIAL U-FLOTILLA 1914-1918
Current stage: Planing - Designing - Resurch.
Current activity: 3D Modeling of U 31.
Status: 1%

[ This Message was edited by: Deamon on 2002-10-09 17:23 ]


  View Profile of Deamon      Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-09 19:29   
Cannot explain it better. I only add that you can do with C all that C++ can do. If you decide not to use C++ classes, use C structs for example. They basically are the same language and allow the same things, but C++ is more 'smart'.

  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
Nephilim


Joined: Feb 28, 2002
Posts: 165
From: Enschede, the Netherlands
Posted: 2002-10-10 14:42   
For the somewhat less initiated, one could
simply put it like this:

C++ is object oriented, whereas C is a
'traditional' programming language.
If you were to make a subsim (we're in a
subsim forum, aren't we?) you could
define an object 'submarine' and give
it parameters as 'speed' and 'max_depth'.

You can create the basic submarine code
(bouyancy and other physics for example)
and apply the whole thing to every
submarine you create, no matter what
the type or size or whatever.

Object oriented programming is without
a doubt the best way to do large apps/games,
but I wouldn't recommend starting with it
until you've mastered a 'traditional'
programming language first.

(A lot of what I said here some of you
already wrote, but maybe my explanation
is better to understand for the laymen.
It took me a long time to figure out
what OO programming was actually good
for, until someone explained it to me
in laymen's terms...)



  View Profile of Nephilim   Email Nephilim   Goto the website of Nephilim      Edit/Delete This Post   Reply with quote
Tinfish


Joined: Feb 27, 2002
Posts: 140
From: New Zealand
Posted: 2002-10-10 15:28   
Thanks Neph and Deamon, your explainations make it all so easy to understand.
A few things I want to get straight, just basic stuff that will help me out.
when making a program, you first need a program to encode and decode the files that you create, so that the files have a format that is unreadable to anyone except the program, correct?


  View Profile of Tinfish   Email Tinfish          Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-10 16:43   
If you want to make it that way, do it. It depends on several things. First is if you want your project to be a commercial product, then normally will be the publisher who tells you what will be encrypted and what not, and your future plannings for the game (if you want it a closed application, with no user modifications, or want to make it easy to modify and expand the product life). Depends on licences you acquire too.

In any case, I recommend you to make the encryption/loading functions by the end. When you compile the program to test it, it's better to wait 10 seconds while the game is loading textures, models, etc... than 30 decrypting and loading. Often you will compile and test dozens of times an hour.


  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
Tinfish


Joined: Feb 27, 2002
Posts: 140
From: New Zealand
Posted: 2002-10-22 23:46   
OK guys, I have decided again just to go straight to C++ but to take it easy.
sofar i am able to write a program which multiplies two intergers together but I have a couple of questions.
Firstly in a line of cout..eg.
cout << " \nHi " what does then \n do?
Secondly.. When a user inputs a number is it possible to have the program reverse then number? if so how?
Cheers guys


  View Profile of Tinfish   Email Tinfish          Edit/Delete This Post   Reply with quote
Tinfish


Joined: Feb 27, 2002
Posts: 140
From: New Zealand
Posted: 2002-10-23 05:13   
One other problem.
This small program is part of the tutorial i'm doing and I compiled it and the compiler found two rpoblems which i cannot identify.
One is in line 35 which I marked out
possible real start of unterminated constant
And in line 51, also marked
unterminated string or character constant
If anyone could help me with those that would be great, cheers



// types.cpp - program to demosntrate the
// advances types used in C++
#include
using namespace std ;
void multiply( long &left, long &right, long &result ) ;
void getValue( const char *message, long *value ) ;

struct values {
long value1 ;
long value2 ;
long result ;
} ;
const int MAX_LEN = 20 ;

int main()
{
values vals ;

cout << " \nProgram to multiply two intergers "
cout << " and display the result " << endl ;
cout << " it will also show the contents of an array " << endl ;

vals.value1 = vals.value2 = vals.result = 0 ;

cout << " \nTwo zeros will end the program. " << endl ;

getValue( " Enter the first interger: " , &vals.value1 ) ;
getValue( " Enter the second interger: " , &vals.value2 ) ;

if( vals.value1 == 0 && vals.value2 == 0 )
break ;

multiply( vals.value1, vals.value2, vals.result ) ;
cout << vals.value1 << " multipled by " ;
cout << vals.value2 << " = " << vals.result" << endl ; Line 35
}

int iVal ;
char message[ MAX_LEN +1 ] ;

for( iVal = 0; iVal < MAX_LEN; iVal++ )
message[ iVal ] = 'A' + iVal ;
message[ iVal ] = '\X00' ;

cout << " \nContents of message[ " << message << ']' << endl ;

char *pc = message ;
for( iVal = 0; iVal < MAX_LEN; iVal++, pc++ )
*pc = '\X00' ;

cout << " \nContents of message[ " << message << ']' << endl ; Line 51

cin.get();return 0 ;

}

// multipy two numbers and put result in third argument
void multiply( long &left, long &right, long &result )
{
result = left * right ;
}

//display message, get value
void getValue( const char *message, long *value )
{
cout << message ;

long result = 0 ;
cin >> result ;
*value = result ;
}


  View Profile of Tinfish   Email Tinfish          Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-23 06:34   
Well. Hope this helps you:

1st question:
'n' is the order to start a new line. Don't know who wrote this tutorial, but if it is a C++ tutorial he must use C++. The n was used in C, of course it works in C++ too, but the command 'cout' has a more adequate parameter: endl. As you see, the C/C++ statement 'cout << "nHi";' in pure C++ would be 'cout << endl << "Hi";'

2nd question:
I don't know what do you mean with 'reverse the number'. Do you mean getting '17' when the user writes '71' ?

3rd and 4th:
The guy who wrote the tutorial probably uploaded it without testing it first.

Where you have:
cout << vals.value2 << " = " << vals.result" << endl ;
you have to put:
cout << vals.value2 << " = " << vals.result << endl ;

Is the " after vals.result what gives error.


Where you have:
cout << " nContents of message[ " << message << ']' << endl ;
you better have to put:
cout << " nContents of message[ " << message << "]" << endl ;

Always use " " when defining a char string. The ' ' are reserved for unique chars. This last depends also of the compiler. I suggest you to use Visual C++ or Borland. I see that the line 45 has the same mistake.

Also make sure you have the iostream.h in the #include libs.

[ This Message was edited by: Manuel Ortega on 2002-10-23 06:41 ]


  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
Leif...


Joined: Mar 01, 2002
Posts: 104
From: Sweden
Posted: 2002-10-23 06:38   
First check is to count the " on a row, and
on row 35 you have tree. Should almost always
be an even number, So there is your problem.

Don't know about row 51 though.

Leif...

ops, Manuel has allready answerd, ah well.


[ This Message was edited by: Leif... on 2002-10-23 06:42 ]


  View Profile of Leif...   Email Leif...   Goto the website of Leif...      Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-23 06:54   
Hehe, simultaneous answers.

I also don't understand completely the line 51 error. It should work as is written.

Which compiler do you use Tinfish?


  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
Tinfish


Joined: Feb 27, 2002
Posts: 140
From: New Zealand
Posted: 2002-10-23 15:39   
Thanks for the help guys.
I dont under stand it eather..
Yes thats what I mean by the reversing numbers thing. the oppostie of what the user enters...
and when i remove the " from
cout << vals.value2 << " = " << vals.result" << endl ;
I get a whole bunch of new erros, lots of them
Im using Dev-C++


  View Profile of Tinfish   Email Tinfish          Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-23 16:06   
I don't know the use of " in that place.

Maybe you should learn with other tutorials.
Try the ones in Gamedev.com:
http://www.gametutorials.com/Tutorials/tutorials.htm

There are very well explained examples there.


  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
jskains


Joined: Aug 08, 2002
Posts: 94
Posted: 2002-10-23 17:08   
I can definatly disagree with the advice here. Learning C and then moving to C++ isn't that aventagous. C teaches you one particular line of thinking and then C++ is a completely different line of thinking.

I think you should begin with the language you plan to stick to. If you want direct programming, go C.. If you seriously plan to learn object oriented programming, you better just start learning C++ straight away.

In summary, learning C and then learning C++ means you will end up UNLEARNING a great deal to become efficient in C++.

JMS


  View Profile of jskains      Edit/Delete This Post   Reply with quote
Manuel Ortega


Joined: Jul 23, 2002
Posts: 184
From: Alicante - Spain
Posted: 2002-10-23 20:05   
As the name says (C++), this language contains ALL the C key words and ALL the C data management methods. If you don't learn C, you can't learn the ++.

If you start learning C++, you don't first learn inheritance and then the 'while' statement or basic structures. The first contents of C++ are C. And of course you can do in simple C all that you can do with the new C++ methods and vice versa, but it's better to use the adequate methods in each case.


  View Profile of Manuel Ortega   Email Manuel Ortega   Goto the website of Manuel Ortega      Edit/Delete This Post   Reply with quote
Goto page ( Previous Page 1 | 2 | 3 Next Page )
Lock this Topic Move this Topic Delete this Topic
Powered by phpBB Version 1.4.4
Copyright © 2000 - 2001 The phpBB Group

phpBB Created this page in 0.042099 seconds.