Forum

> > Off Topic > C++ Tutorial
Forums overviewOff Topic overviewLog in to reply

English C++ Tutorial

128 replies
Page
To the start Previous 1 2 3 4 5 6 7 Next To the start

old C++ Tutorial

archmage
User Off Offline

Quote
I am learning Java, and I bought this half-ton book. Tis not fun to read. Anyone know a tutorial that explains Java and OOP? A good one that I will be writing GUIs in a month or two.
edited 1×, last 20.07.10 11:08:29 pm

old Re: C++ Tutorial

YellowBanana
BANNED Off Offline

Quote
Big Java, pm me for a link
I don't really see the point in learning java tho, i'd say c ( or c++, c#) is better to learn.

Also, it's quite hard to fully understand programming ( doesn't matter if it's java or c++) in 2 months. It takes quite a lot of time to be honest.

old Re: C++ Tutorial

Flacko
User Off Offline

Quote
I think there are java libraries to program GUIs so you may start programming them in like 2 hours?

old Re: C++ Tutorial

DC
Admin Off Offline

Quote
YellowBanana has written
Big Java, pm me for a link

why so complicated? I hope that you're not sharing commercial ebooks or other illegal stuff via pm. this would be a crucial rule violation.

and if it's not illegal: why don't you post the link right here in the thread so people can see it?

old Re: C++ Tutorial

YellowBanana
BANNED Off Offline

Quote
It's not like i want to share my book that I bought with my own money to the whole world. I got this book through my university. I paid money for it indirectly.

old Re: C++ Tutorial

archmage
User Off Offline

Quote
Well, no thanks I already have a biiiig book I was hoping for an online tut.

Edit:
I plan once I understand Java to download Java 3D and create 3d games with java would java be a good language for games?
edited 1×, last 20.07.10 06:27:26 am

old Re: C++ Tutorial

DC
Admin Off Offline

Quote
you can use java to write games. it's a good choice if you want your game to be cross plattform compatible. however it will require more ram as a c/c++ game for example because the game needs ram and the java virtual machine needs some and the overall execution speed can be slightly slower (even though the java VMs are pretty good by now).

biggest problem I see with that is that the 3D engines for java don't seem to be as powerful as engines for c/c++. you shouldn't expect to get high-end state of the art 3D graphics. I didn't tried it myself though. just judging from videos/demos I saw.

old Re: C++ Tutorial

bezmolvie
User Off Offline

Quote
Java is extremely open ended, and can do nearly anything. However, it is very hard compared to scripting languages like Lua. The Java Tutorials is a free online tutorial for beginners.

old Re: C++ Tutorial

archmage
User Off Offline

Quote
@Bloodshot: Thanks.
@DC: I downloaded a few games, and watch a vid. I think your right, but isn't a C++ compiler a few thousand dollars? That is what I heard. Is C++ structured?

old Re: C++ Tutorial

Flacko
User Off Offline

Quote
The gcc compiler is free and open source, I think there aren't many paid compilers.
You should use mingw32 and Dev-C++ if you are using windows or maybe cygwin and Dev-C++.

old Re: C++ Tutorial

archmage
User Off Offline

Quote
Okay thanks I guess I will learn C++ instead. Isn't C++ and Java very similar? That is what this book says.
Edit:
Know any good IDEs (C++)?
I guess I will need a tut at least until I get another book. I would google for my self but I don't know that I would get a good tut.

old Re: C++ Tutorial

Flacko
User Off Offline

Quote
Somewhat...
Don't expect C++ to be as easy as java though, you will prefer to do some things by yourself instead of using the standard libraries (ie: Reinventing the wheel) because including too many of those will result in a huge executable

You will surely need some references and tuts:
http://www.cplusplus.com/
http://www.cprogramming.com/tutorial.html
http://www.cppgameprogramming.com/ <-There we have a forum and some cool tutorials also, I'm a moderator

old Re: C++ Tutorial

Lee
Moderator Off Offline

Quote
Java is considered by some to be the sissy boy of the manly programming world and others as a brilliant advance towards programming salvation. Linus of course bashes C++ and is ambivalent towards Java, but then again Linus is a bit of a loony nowadays.

Anyways, I'd suggest that you start with Java unless you're actually interested in learning the lower level galores (or gores) of programming. To be honest, most of the features in C++ will look like bugs to the untrained eye, and it takes a hell of a lot of patience for someone starting with the language to actually progress unless you're familiar with most of the programming paradigms at a higher level or are well versed in the many theorems of logic and discrete mathematics.

And of course, the entire discipline of dynamic languages are considered to be just so way out there that they ain't got nothing on nobody... that's where the Python, Ruby, Lua, Perl, and even Pascal guys are sitting at T_T

-Edit: Albeit if it's for game programming, if you're going with the OpenGL toolkit, C/C++'s implementation is considered by many to be native and all other implementations a derivative thereof, so you may be better off with finding documentation and tutorial (as Flacko pointed out above). And I haven't heard of many GL toolchains on Java except for Khronos, which is an unbelievable hassle to work with since it doesn't implement the traditional BEGIN ... END transaction model. But since by then programming techniques should be secondary to the thought process itself, I suggest that you begin with learning about the general concepts of programming with Java and work your way down to C++, which in some ways of speaking, syntactically similar to Java.

old Re: C++ Tutorial

archmage
User Off Offline

Quote
Edit:

Why does this crash.
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
#include <iostream>
#include <fstream>
#include <string>
#include <new>
using namespace std;

string* file_data;
int filelc(0);

int main() {
	file_data = new (nothrow) string[0];
	ifstream file ("text.txt");
	if ( file.is_open() )
	{
	   int i = 0;
	   while (! file.eof() )
	   {
	   		getline(file, file_data[i]);
			i++;
			filelc = i;
		}
		file.close();
	}
	else cout << "Error: Can not open file.";
	int l;
	for ( l = 0; l < filelc; l++ )
		cout << file_data[l] << endl;

	while ( true ){
	}	

	return 0;
}
edited 6×, last 21.07.10 09:24:38 am

old Re: C++ Tutorial

Lee
Moderator Off Offline

Quote
1. file_data = new (nothrow) string[0];
You initialized file_data into a size 0 container for string

2. getline(file, file_data[i]);
file.getline(buffer, size); - Where buffer holds reference to an initialized char array of length greater than size.

3. while ( true ){}
infinite loop...

The following is the equivalent of what I think you wanted to do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

int main() {
	stringstream data;
	ifstream file ("doubles.txt");
	if (file.is_open()){
    	 while (!file.eof())
    		 data << (char) file.get();
    	 file.close();
	}
	else cout << "Error: Can not open file.";
	cout << data.str() << endl;

	return 0;
}

The following splits a file by line, no matter how many characters are in a line:

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
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {
	stringstream data;
	vector<string> container;
	ifstream file ("doubles.txt");

	if (file.is_open()){
		char cur;
		while (!file.eof()){
			cur = file.get();
			data << cur;
			if(cur=='\n'){
				container.push_back(data.str());
				data.str("");
			}
		}
		file.close();
	}
	else cout << "Error: Can not open file.";
	for(int i=0;i<container.size();i++)
		cout << container[i] << endl;

	return 0;
}

For larger files, use the getline(&char, buf_size) equivalent and check for the last char. You can also implement a native container but it's a little trickier and you need to be familiar with C/C++'s memory allocation mechanisms that is apparently considered "ugly" by the C++ camp (in favor of the default new and delete constructors which are basically just layered on top of malloc and free).
edited 1×, last 21.07.10 01:25:34 pm

old Re: C++ Tutorial

DoP3
User Off Offline

Quote
I've heard allot of C#, apparently it's better than C++ but I'm not sure, what do you guys think about it?

old Re: C++ Tutorial

Flacko
User Off Offline

Quote
-GaS- has written
I've heard allot of C#, apparently it's better than C++ but I'm not sure, what do you guys think about it?


I think that a Microsoft propietary language is not better than C++

Btw DB: It seems like I'm a bit late to answer your question

old Re: C++ Tutorial

YellowBanana
BANNED Off Offline

Quote
Depends on what you want. C++ is good if things need to be fast, a very fast server, d3d rendering, drivers etc.

With c# it's much easier to write big programs, GUI and to use stuff like Silverlight.

C# is pretty equivalent to JAVA, except that it uses the .NET framework. I've written a few programs for Cs2d in C# ( like the RCON tool which u can find under files/misc.)

old Re: C++ Tutorial

archmage
User Off Offline

Quote
@Lee:
Thanks I mostly just wanted to store each line of a file in dynamic memory.
Edit:
the reason for the infinite loop is so that I can see the output.
To the start Previous 1 2 3 4 5 6 7 Next To the start
Log in to replyOff Topic overviewForums overview