Page 1 of 6 [ 90 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

J-P
Velociraptor
Velociraptor

User avatar

Joined: 21 Oct 2008
Age: 36
Gender: Male
Posts: 487
Location: Montréal,Québec,Canada

06 May 2012, 11:40 pm

Recently i decided to try to learn C++ on an website. Yeah that an hard language but i like it. As i'm patient and persevering i know with time i can do something good. I'm in OOP(Object oriented programmation) part of lesson. Hard technique but very useful. I still have difficult ot determine what go in cpp and header but i will be used with time i suposse. I suposse c++ is an practice thing. I think i love this language so much, that going to kill myself. I explain:When i'm passionate of something i'm just absorbed with it and only do that thing at point my mood is affected. I hate it but i know aspies tend to be like that. To come back to C++,when i learn much more i think to have an non graphical project because graphics systems are not my level and are hard to create. I don't mean by Windows with menu but like an map with object. I'm too noob for that....maybe in fews months maybe 1 year if i continue. For now my actual project for next months is an non graphical RPG.

But like i said that not for tommorow or next month. Maybe like 5 to 10 months after i finish lessons. I don't have illusions for now i risk to be disappointed. I'm realist but with lessons i see more how i can do things. Slowly but for surely. Anyway for more big project i prefer to have an team. By team i mean coders,graphics guys(art work and game graphics,musician and somes of what i mention for mapping(we can do two task each i suppose). For now i just do lessons. If someone here do C++ how many time you take for get acceptable skill? Talking about mapping and graphic that seem complicated because for the program don't lag and have acceptable frame i need to have light code and graphics itself count. My math skill sucks hard so don't know if i can be good programmer as an bad mathematician. Somes things on lessons i barely remember but i also don't have the experience. With experience i will remember.

I still remember with adress or pointer(don't remember clearly) to set it to 0 otherwise i can alter Windows. I like the possibility that this language have to offer. For first real project i don't have any idea for now. The site thjat give free lessons give us some RPG style things for exemple and learning i think to modify it the best i can just for practice. Add somes things like player enter the character name for exemple. Easy to do but i don't know in OOP if it's really easy. If someday i made friends that are like me and passionned of this thing we can do an common project but for nom i'm a lonely future programmer

Do peoples here will think of my passions

PS: Dont hesit to correct me if i'm wrong that will help me in future

J-P



mglosenger
Velociraptor
Velociraptor

User avatar

Joined: 19 Aug 2011
Age: 152
Gender: Male
Posts: 445

07 May 2012, 7:21 am

Pointers are addresses.

As far as learning C++, I learned C first, which I'm sure made it easier.

The basic concepts of C++ are not difficult, but probably the difficulty you will have is in determining how to structure your objects - what sorts of objects to define, what all should do what, etc.

And, personally, I know that my early code seemed pretty horribly written when I looked at it later.. but it worked :)

Just write some code, make it work, and keep doing that over and over and you'll learn stuff.

As far as needing to know mathematics for graphical coding, that is true mostly for 3D programming, although it's less necessary than it used to be now that Direct3D and OpenGL and the like exist.. still, ultimately you do need to know the basic ideas, especially to make the code as efficient as possible. It's really not too complicated, though - all the 3D theory was determined years ago by computer scientists and many books targeted at all sorts of audiences have been written about it.

However, I would suggest writing more basic things in C++ first, which it sounds like is what you are doing.

If you find C++ too complicated to start, try using C. C++ is mostly just C with strict compiler checking on object classes.



J-P
Velociraptor
Velociraptor

User avatar

Joined: 21 Oct 2008
Age: 36
Gender: Male
Posts: 487
Location: Montréal,Québec,Canada

07 May 2012, 8:08 am

mglosenger wrote:
Pointers are addresses.

As far as learning C++, I learned C first, which I'm sure made it easier.

The basic concepts of C++ are not difficult, but probably the difficulty you will have is in determining how to structure your objects - what sorts of objects to define, what all should do what, etc.

And, personally, I know that my early code seemed pretty horribly written when I looked at it later.. but it worked :)

Just write some code, make it work, and keep doing that over and over and you'll learn stuff.

As far as needing to know mathematics for graphical coding, that is true mostly for 3D programming, although it's less necessary than it used to be now that Direct3D and OpenGL and the like exist.. still, ultimately you do need to know the basic ideas, especially to make the code as efficient as possible. It's really not too complicated, though - all the 3D theory was determined years ago by computer scientists and many books targeted at all sorts of audiences have been written about it.

However, I would suggest writing more basic things in C++ first, which it sounds like is what you are doing.

If you find C++ too complicated to start, try using C. C++ is mostly just C with strict compiler checking on object classes.


yeah pointer are adresses thanks. I will begin by basic for sure maybe write some no where code for practice i'm not ready to do crazy thing anyway i need more experience. In which way C and C++ is similar? They can be used together? Similar command? Anyway i prefer 2D graphical(i prefer 2D i'm a classic gamer) Like i said im at learning step i need more i don't have enough knowledge i will start with somes practice on basic things i learn. I will take book if i need it.



g1
Emu Egg
Emu Egg

User avatar

Joined: 6 May 2012
Age: 56
Gender: Male
Posts: 1

07 May 2012, 10:30 am

I sort-of did the same as you, but with Objective-C.

C++ is a version of C that's aimed at making code into re-usable objects. You definitely need to understand how C pointers work in order master C++. If you're like me, you might struggle with C++ syntax because it's pretty thick with shorthand that doesn't seem obvious (to me, at least; probably why I like Objective-C better).

I think I was lucky to have learned RealBasic before I dove into Objective-C because it helped me to learn object-oriented programming with a plain-english programming language.

Don't worry too much about a "math" weakness --I went through most of my life thinking I was a dummy because I couldn't do basic math (don't ask me to multiply two numbers). Turned out that I'm good at stuff like algebra, geometry, even calculus. I think it's fun to solve problems with it. You might find the same thing if you can get around some silly roadblock in your mind. You'll find that C and C++ have great resources for handling mathematics.



MyFutureSelfnMe
Veteran
Veteran

User avatar

Joined: 26 Feb 2010
Age: 46
Gender: Male
Posts: 1,385

07 May 2012, 10:43 am

That's the first time I've ever heard anyone say they like Objective C syntax.



J-P
Velociraptor
Velociraptor

User avatar

Joined: 21 Oct 2008
Age: 36
Gender: Male
Posts: 487
Location: Montréal,Québec,Canada

07 May 2012, 1:50 pm

MyFutureSelfnMe wrote:
That's the first time I've ever heard anyone say they like Objective C syntax.


OOP can be an pain but we need to pass by there



marshall
Veteran
Veteran

User avatar

Joined: 14 Apr 2007
Gender: Male
Posts: 10,752
Location: Turkey

07 May 2012, 2:07 pm

I've only coded recreationally (for the most part) and prefer writing procedural type code with straight C syntax. OO style using C++ syntax is necessary for large programs with complex data structures. It can be a little tedious to use it for a more simple program written mostly for recreational purposes.

Writing code in straight C gives you a much better understanding of the underlying structure of a program with regards to how physical memory is managed. Using objects hides what's going on behind the scenes a little bit. For example, an object's constructor might allocate a big chunk of RAM behind the scenes when it appears you're simply initializing a local date element on the stack. In a way it is nice to simply let constructors and destructors deal with memory management since normally forgetting to free up chunks of memory in an inner loop may grind the whole computer to a halt in a relatively short time.

I think it's best to learn straight C syntax first and then go on to OO style and C++. But if you ever program professionally its mostly going to be in OO style (no matter which language you use) because it's way more efficient for large projects.



Burzum
Veteran
Veteran

User avatar

Joined: 26 Apr 2011
Age: 33
Gender: Male
Posts: 1,205

07 May 2012, 2:33 pm

J-P wrote:
I still remember with adress or pointer(don't remember clearly) to set it to 0 otherwise i can alter Windows


http://en.wikipedia.org/wiki/Protected_mode

Trying to access memory that your application doesn't own will cause a segfault. You won't alter Windows.



J-P
Velociraptor
Velociraptor

User avatar

Joined: 21 Oct 2008
Age: 36
Gender: Male
Posts: 487
Location: Montréal,Québec,Canada

07 May 2012, 2:44 pm

Burzum wrote:
J-P wrote:
I still remember with adress or pointer(don't remember clearly) to set it to 0 otherwise i can alter Windows


http://en.wikipedia.org/wiki/Protected_mode

Trying to access memory that your application doesn't own will cause a segfault. You won't alter Windows.


Oh yeah i learn about this thing recently(protected). Segfault? I have much to learn! Maybe because i'm far from end of lessons

marshall wrote:
I've only coded recreationally (for the most part) and prefer writing procedural type code with straight C syntax. OO style using C++ syntax is necessary for large programs with complex data structures. It can be a little tedious to use it for a more simple program written mostly for recreational purposes.

Writing code in straight C gives you a much better understanding of the underlying structure of a program with regards to how physical memory is managed. Using objects hides what's going on behind the scenes a little bit. For example, an object's constructor might allocate a big chunk of RAM behind the scenes when it appears you're simply initializing a local date element on the stack. In a way it is nice to simply let constructors and destructors deal with memory management since normally forgetting to free up chunks of memory in an inner loop may grind the whole computer to a halt in a relatively short time.

I think it's best to learn straight C syntax first and then go on to OO style and C++. But if you ever program professionally its mostly going to be in OO style (no matter which language you use) because it's way more efficient for large projects.


so in my case c++ is useless? or i need to learn both depending of what i do?



Evinceo
Deinonychus
Deinonychus

User avatar

Joined: 13 Apr 2012
Age: 32
Gender: Male
Posts: 392

07 May 2012, 4:09 pm

Okay, C++ is C with more possibilities. Game programming is much easier with C++ because games tend to be much easier to implement with Objects, and C++'s OOP support is much better than C's. They have the same syntax (commands, expressions, etc) for the most part, but I can see where you're running into a problem-header files and other compilation headaches take up way more time and effort than you'd expect.

As far as OOP goes, if it does not make your program easier, don't use it. Almost every game will benefit from OOP, though plenty of important ones where written in straight C since it is possible to write OO code in C (with structs).



RazorEddie
Veteran
Veteran

User avatar

Joined: 18 Jan 2012
Age: 55
Gender: Male
Posts: 610

07 May 2012, 4:24 pm

J-P wrote:
so in my case c++ is useless? or i need to learn both depending of what i do?

C++ is a superset of C. It contains all of the C functionality plus all of the extra OOP stuff. You can start off with straight C syntax then as you get used to it you can start adding in the OOP stuff. That's the way I learned C++.


_________________
I stopped fighting my inner demons. We're on the same side now.


MyFutureSelfnMe
Veteran
Veteran

User avatar

Joined: 26 Feb 2010
Age: 46
Gender: Male
Posts: 1,385

07 May 2012, 4:31 pm

I would spend enough time in C to feel like I had a good grasp of pointers and memory management (malloc/free), and then rename a .c file to .cpp and start fleshing out some concepts as classes instead of just functions.

OO helps a lot in the management of code that's more complex than just a couple thousand line sample, you will find fleshing existing code out further and adding features becomes more sensible. There are relatively few reasons to code in straight C anymore once you have a firm grasp of C++.



Ancalagon
Veteran
Veteran

User avatar

Joined: 25 Dec 2007
Age: 46
Gender: Male
Posts: 2,302

07 May 2012, 4:58 pm

J-P wrote:
Segfault?

Segfault is short for segmentation fault, which is a kind of error. I think it's called a general protection fault on windows.

The operating system gives a program a specific range of allowable memory addresses, and if it tries to use something not in the range, then the operating system steps in, kills the program, and gives an error message. If you get one of these, then you know you did something that didn't make sense with pointers or array accesses, although finding out exactly what you did can be quite a pain.


_________________
"A dead thing can go with the stream, but only a living thing can go against it." --G. K. Chesterton


MyFutureSelfnMe
Veteran
Veteran

User avatar

Joined: 26 Feb 2010
Age: 46
Gender: Male
Posts: 1,385

07 May 2012, 5:29 pm

Your application owns ranges of virtual memory addresses [base...base+size] that it has allocated from the OS. Sometimes these are contiguous with each other and sometimes not. If you attempt to read from or write to a pointer that does not fall within one of those ranges, you get a General Protection Fault on Windows, and the signal SIGSEGV (segmentation fault) on other OSes or with GCC based compilers on Windows. The default handler for SIGSEGV kills the application. Theoretically, on Linux it's possible to catch the SIGSEGV, have your handler called, and continue execution (although you probably do not want to do this), on Windows it's not possible to set up a custom handler. At any rate, it should not be possible to coerce a publically released application to cause this fault, you need to work out all of them as part of your bug shaking process :)

Years ago, when working in Real Mode (DOS), these things weren't caught elegantly and you could write to any memory including that owned by the OS, causing potential chaos. Mankind has evolved further since then.

You can usually root cause these types of issues very quickly by running a "Debug build" of your app in a debugger. As soon as the fault occurs, the debugger will kick in and provide you with a UI for... debugging.

Good luck.



J-P
Velociraptor
Velociraptor

User avatar

Joined: 21 Oct 2008
Age: 36
Gender: Male
Posts: 487
Location: Montréal,Québec,Canada

07 May 2012, 7:03 pm

Evinceo wrote:
Okay, C++ is C with more possibilities. Game programming is much easier with C++ because games tend to be much easier to implement with Objects, and C++'s OOP support is much better than C's. They have the same syntax (commands, expressions, etc) for the most part, but I can see where you're running into a problem-header files and other compilation headaches take up way more time and effort than you'd expect.

As far as OOP goes, if it does not make your program easier, don't use it. Almost every game will benefit from OOP, though plenty of important ones where written in straight C since it is possible to write OO code in C (with structs).


Game developping is not in my skill i'm still noob :lol:

Header file is an pain for me..i mean as i'm still noob, i still have difficult to know where things go but i suposse that come with practice



MyFutureSelfnMe wrote:
Your application owns ranges of virtual memory addresses [base...base+size] that it has allocated from the OS. Sometimes these are contiguous with each other and sometimes not. If you attempt to read from or write to a pointer that does not fall within one of those ranges, you get a General Protection Fault on Windows, and the signal SIGSEGV (segmentation fault) on other OSes or with GCC based compilers on Windows. The default handler for SIGSEGV kills the application. Theoretically, on Linux it's possible to catch the SIGSEGV, have your handler called, and continue execution (although you probably do not want to do this), on Windows it's not possible to set up a custom handler. At any rate, it should not be possible to coerce a publically released application to cause this fault, you need to work out all of them as part of your bug shaking process :)

Years ago, when working in Real Mode (DOS), these things weren't caught elegantly and you could write to any memory including that owned by the OS, causing potential chaos. Mankind has evolved further since then.

You can usually root cause these types of issues very quickly by running a "Debug build" of your app in a debugger. As soon as the fault occurs, the debugger will kick in and provide you with a UI for... debugging.

Good luck.


I use Code::Block so it have an debugger



marshall
Veteran
Veteran

User avatar

Joined: 14 Apr 2007
Gender: Male
Posts: 10,752
Location: Turkey

08 May 2012, 10:57 am

RazorEddie wrote:
J-P wrote:
so in my case c++ is useless? or i need to learn both depending of what i do?

C++ is a superset of C. It contains all of the C functionality plus all of the extra OOP stuff. You can start off with straight C syntax then as you get used to it you can start adding in the OOP stuff. That's the way I learned C++.


Yea. I'd say you'll eventually want to know both. It's just that crap like operator overloading and templates make using C++ libraries really confusing IMO. It's a lot easier to understand whats going on by using C library functions alone when you're first learning.

I'd also make a distinction between learning the language syntax itself and learning a programming style/convention. Technically it is possible write programs in an OOP style with any language. Using the C++ extension just makes things much more efficient for OOP (i.e. the code is clearer and you don't need as many lines of code to do it as you would using only C syntax and functions).