Help an old programmer
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
.h should contain signatures (interfaces if you'd like) .cpp should contain implementation (concretes if you'd like)
Seulement, dans certains cas, n'est-ce pas, on n'entend guère que ce qu'on désire entendre et ce qui vous arrange le mieux... [^] Joe never complained of anything but ever did his duty in his way of life, with a strong hand, a quiet tongue, and a gentle heart [^]
-
.h should contain signatures (interfaces if you'd like) .cpp should contain implementation (concretes if you'd like)
Seulement, dans certains cas, n'est-ce pas, on n'entend guère que ce qu'on désire entendre et ce qui vous arrange le mieux... [^] Joe never complained of anything but ever did his duty in his way of life, with a strong hand, a quiet tongue, and a gentle heart [^]
Thanks. I sort of know that much - but (for example) in C# I would have something like
bool myFlag;
bool MyFlag
{ get return myFlag; }
{ set myFlag = value; }Now I (know?) in C++ I need to write my own getters and setters which is fine - but do I put the field in the .h? Do the getters and setters also go in the .h? or just the definition of the getter and setter but the implementation goes in the .cpp? (Not looking for an answer to that specifically - but that';s the sort of question I find myself asking, and then taking time to look up, rather than getting on with the development.
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
Thanks. I sort of know that much - but (for example) in C# I would have something like
bool myFlag;
bool MyFlag
{ get return myFlag; }
{ set myFlag = value; }Now I (know?) in C++ I need to write my own getters and setters which is fine - but do I put the field in the .h? Do the getters and setters also go in the .h? or just the definition of the getter and setter but the implementation goes in the .cpp? (Not looking for an answer to that specifically - but that';s the sort of question I find myself asking, and then taking time to look up, rather than getting on with the development.
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
in your .h you declare everything that your implementation needs to expose 'publicly' and that's it so... no. No need to declare private fields in .h. When thinking about what to put in the .h then you can consider it as being the 'same' thing as a C# abstract class which would be purely abstract. By purely I mean that it should not provide one line of implementation but just signatures : a kind of mix between interface and abstract C# types
Seulement, dans certains cas, n'est-ce pas, on n'entend guère que ce qu'on désire entendre et ce qui vous arrange le mieux... [^] Joe never complained of anything but ever did his duty in his way of life, with a strong hand, a quiet tongue, and a gentle heart [^]
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
I'd definitely recommend something like 'Effective C++' http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876[^] It'll give you lots to look at, it has a focus on the C++ specific type things that may be unfamiliar from a C# background (like const functions and iterators and so on). What's nice about the book is that it's in bite-sized chunks, so you can really dip in and out in any order you like. With the getters and setters, you typically do the following btw: 1. All off the declarations of the functions go in the header (the declaration just specifies the signature). 2. All of the definitions of the functions (i.e. their actual content) goes in the cpp file. However, you can actually put the definition in the h file as well, what happens here is that generally the compiler will treat them as inline, so it will actually write the content of the function when they're called - not write a method call. class Summat { private: int m_nNumber; public: int GetNumber() const { return m_nNumber; } void SetNumber(int nNumber) { m_nNumber = nNumber; } } Good luck!
My Blog: www.dwmkerr.com My Charity: Children's Homes Nepal
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
Well there are really many and wonderful books, but as i see you don't have much time to read. I suggest CPlusPlus. It's really useful site with all kind of information about the language. If you need some information i am sure you gonna find it in there.
Microsoft ... the only place where VARIANT_TRUE != true
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
It sounds like all you need to do is to spend a little time reading some well written C++ source code and you'll pick up what you need pretty quickly. Download some articles from Code Project in a subject area you're interested enough in to read the code, or even one of mine, and find a style that suits you. There are many ways to write C++ from the definitely not recommended MFC style to the serious egg heads only Boost style. You can do as much as possible with template meta programming and end up with 20 lines of mind bending self referential complexity that is the entire program or lay out every minute procedural step just one level removed from doing it in assembly language. Sometimes a balance is best and sometimes a compromise is the worst of both worlds. The art of C++ is choosing the right way for the job in hand.
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
_Maxxx_ wrote:
10% coding, 20% debugging and 70% Googling
I bake your powder sire, but that does not leave too much time for CodeProjecting,
It is a paradox that paradoxes would actually exist in reality. That means of course that they don't exist. However, they do!
∫(Edo)dx = Tzumer ∑k(this.Kid)k = this.♥
-
_Maxxx_ wrote:
10% coding, 20% debugging and 70% Googling
I bake your powder sire, but that does not leave too much time for CodeProjecting,
It is a paradox that paradoxes would actually exist in reality. That means of course that they don't exist. However, they do!
∫(Edo)dx = Tzumer ∑k(this.Kid)k = this.♥
Googling / Codeprojecting - I count 'em the same!
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
I'd definitely recommend something like 'Effective C++' http://www.amazon.com/Effective-Specific-Improve-Programs-Designs/dp/0321334876[^] It'll give you lots to look at, it has a focus on the C++ specific type things that may be unfamiliar from a C# background (like const functions and iterators and so on). What's nice about the book is that it's in bite-sized chunks, so you can really dip in and out in any order you like. With the getters and setters, you typically do the following btw: 1. All off the declarations of the functions go in the header (the declaration just specifies the signature). 2. All of the definitions of the functions (i.e. their actual content) goes in the cpp file. However, you can actually put the definition in the h file as well, what happens here is that generally the compiler will treat them as inline, so it will actually write the content of the function when they're called - not write a method call. class Summat { private: int m_nNumber; public: int GetNumber() const { return m_nNumber; } void SetNumber(int nNumber) { m_nNumber = nNumber; } } Good luck!
My Blog: www.dwmkerr.com My Charity: Children's Homes Nepal
Thanks Dave - I'll certainly take a look at the book.
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
It sounds like all you need to do is to spend a little time reading some well written C++ source code and you'll pick up what you need pretty quickly. Download some articles from Code Project in a subject area you're interested enough in to read the code, or even one of mine, and find a style that suits you. There are many ways to write C++ from the definitely not recommended MFC style to the serious egg heads only Boost style. You can do as much as possible with template meta programming and end up with 20 lines of mind bending self referential complexity that is the entire program or lay out every minute procedural step just one level removed from doing it in assembly language. Sometimes a balance is best and sometimes a compromise is the worst of both worlds. The art of C++ is choosing the right way for the job in hand.
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
Matthew Faithfull wrote:
spend a little time reading some well written C++ source code
It's the "well written" bit that's hard. There is just SO MUCH1 out there, finding something that is well formatted and not just a snipped to answer some question it a hard slog! I'm off to see what this Boost style's all about ;) Oh - and templates ain't where I want to be! I want to understand what I'm doing, but not continually have to go back and refactor as I learn better ways!
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
It sounds like all you need to do is to spend a little time reading some well written C++ source code and you'll pick up what you need pretty quickly. Download some articles from Code Project in a subject area you're interested enough in to read the code, or even one of mine, and find a style that suits you. There are many ways to write C++ from the definitely not recommended MFC style to the serious egg heads only Boost style. You can do as much as possible with template meta programming and end up with 20 lines of mind bending self referential complexity that is the entire program or lay out every minute procedural step just one level removed from doing it in assembly language. Sometimes a balance is best and sometimes a compromise is the worst of both worlds. The art of C++ is choosing the right way for the job in hand.
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
Just skimmed a couple of your articles - really liked the patterns one btw. It does help looking at code like that - esp. as you put your braces in the "correct" position - and not on the same line as the function like some!
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
Just skimmed a couple of your articles - really liked the patterns one btw. It does help looking at code like that - esp. as you put your braces in the "correct" position - and not on the same line as the function like some!
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
Thanks, I'm glad the correct bracketing is appreciated. That patterns article is well out of date though, please don't use the source directly, it should have a health warning. The style is alright from what I remember and the ideas are sound but I wrote it over 6 years ago and there are horrible bugs in the sample code. :-O A rewrite is due shortly but first I have to get the next QOR article finished which is based on the updated version of the same codebase. Enjoy your C++ :)
"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)
-
Thanks Dave - I'll certainly take a look at the book.
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
No probs - have fun!
My Blog: www.dwmkerr.com My Charity: Children's Homes Nepal
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
C# has already designed away most of the tedium of C++.
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
I am an experienced programmer of many a language - most recently C#. I am attempting to write a program using Cocos2d-X (and, therefore, C++) (based loosely upon some existing code written in Cococs2d-iPhone (and, therefore, Objective C) Can someone recommend some site or book (of the cheap variety!) which will give me the'cheat sheet' version of C++ What I mean is, I don't want to sit down and learn C++ formally - I just want to look at how things "should be done" (e.g. what goes in .h and what in .cpp, are there such thing as interfaces - or do I just use base classes) preferably with a C# bent. I so far have found my development time to be 10% coding, 20% debugging and 70% Googling - so it would be nice to have one or two resources to hand rather than looking up each individual issue. thanks in advance for your kind help :rose:
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
C++ isn't a simple beast but I'm sure you know that. I could rattle on about header files for a good ten minuets. If you get really stuck, feel free to drop me an email
Thanks! I'll keep that in mind;
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
C# has already designed away most of the tedium of C++.
Awesome - thanks!
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
I tried that, but when I went back in time I just ended up going to the pub with myself! Wow- I'm good company ;)
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')