Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Help an old programmer

Help an old programmer

Scheduled Pinned Locked Moved The Lounge
csharpc++wpfhelpios
20 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    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')

    G Offline
    G Offline
    Guirec
    wrote on last edited by
    #2

    .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 [^]

    L 1 Reply Last reply
    0
    • G Guirec

      .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 [^]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #3

      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')

      G 1 Reply Last reply
      0
      • L Lost User

        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')

        G Offline
        G Offline
        Guirec
        wrote on last edited by
        #4

        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 [^]

        1 Reply Last reply
        0
        • L Lost User

          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')

          D Offline
          D Offline
          Dave Kerr
          wrote on last edited by
          #5

          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

          L 1 Reply Last reply
          0
          • L Lost User

            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')

            A Offline
            A Offline
            Argonia
            wrote on last edited by
            #6

            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

            1 Reply Last reply
            0
            • L Lost User

              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')

              M Offline
              M Offline
              Matthew Faithfull
              wrote on last edited by
              #7

              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)

              L 2 Replies Last reply
              0
              • L Lost User

                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')

                J Offline
                J Offline
                Joezer BH
                wrote on last edited by
                #8

                _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.♥

                L 1 Reply Last reply
                0
                • J Joezer BH

                  _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.♥

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  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')

                  1 Reply Last reply
                  0
                  • D Dave Kerr

                    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

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    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')

                    D 1 Reply Last reply
                    0
                    • M Matthew Faithfull

                      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)

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      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')

                      1 Reply Last reply
                      0
                      • M Matthew Faithfull

                        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)

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        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')

                        M 1 Reply Last reply
                        0
                        • L Lost User

                          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')

                          M Offline
                          M Offline
                          Matthew Faithfull
                          wrote on last edited by
                          #13

                          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)

                          1 Reply Last reply
                          0
                          • L Lost User

                            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')

                            D Offline
                            D Offline
                            Dave Kerr
                            wrote on last edited by
                            #14

                            No probs - have fun!

                            My Blog: www.dwmkerr.com My Charity: Children's Homes Nepal

                            1 Reply Last reply
                            0
                            • L Lost User

                              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')

                              R Offline
                              R Offline
                              RichardGrimmer
                              wrote on last edited by
                              #15

                              This might just help[^]

                              C# has already designed away most of the tedium of C++.

                              L 1 Reply Last reply
                              0
                              • L Lost User

                                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')

                                A Offline
                                A Offline
                                AspDotNetDev
                                wrote on last edited by
                                #16

                                The fast way.

                                Thou mewling ill-breeding pignut!

                                L 1 Reply Last reply
                                0
                                • L Lost User

                                  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')

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #17

                                  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

                                  L 1 Reply Last reply
                                  0
                                  • L Lost User

                                    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

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #18

                                    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')

                                    1 Reply Last reply
                                    0
                                    • R RichardGrimmer

                                      This might just help[^]

                                      C# has already designed away most of the tedium of C++.

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #19

                                      Awesome - thanks!

                                      MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                                      1 Reply Last reply
                                      0
                                      • A AspDotNetDev

                                        The fast way.

                                        Thou mewling ill-breeding pignut!

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #20

                                        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')

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups