Messing Around with C++ *Faceplant*

Discussion in 'Tech Discussion' started by sal880612m, Feb 27, 2016.

Thread Status:
Not open for further replies.
  1. sal880612m

    sal880612m As I thought, love was a status effect! ~ICDS

    Joined:
    Oct 20, 2015
    Messages:
    2,224
    Likes Received:
    1,858
    Reading List:
    Link
    So I have been messing around with C++ trying to do something and realized there was a much simpler way to go about it that I missed because I'm still a C++ noob.

    Basically I was using what I consider C-style polymorphism so that

    Class A { //class definition here }
    Class B { //class defintion here; vector<Class A>; }
    Class C { //class definition here; vector<Class B>; } <-is pure virtual and the level where behaviour of
    of Class A and Class B objects are determined.
    Class D: public C {//class definition here} <-the actual information and interface I want to work with

    with classes A and B having pointers to functions outside of their classes when I could have done:

    Class A { //class definition here } <-is pure virtual
    Class B { //class definition here; vector<Class A*> } <-Also pure virtual
    Class C { //class definition here: vector<Class B*> } <-Still pure virtual
    Class D: public A { //class definition here; }
    Class E: public B { //class definition here; vector<Class A*> } vector points to class A part of Class D objects
    Class F: public C { //class definition here; vector<Class B*> } vector points to class B part of Class E objects

    I know the latter seems like more work, but in the long run it would be much, much cleaner, neater code. Primarily because objects could be built from the ground up in terms of functions and data. Whereas the former would require that they be defined from the top down, which makes it painful to describe and unclear how to use.

    Needless to say, I feel dumb at the moment and needed a break. On the other hand I did have it working in such a way that at least I could use the code. In my defense I am actually still a C++ noob and haven't played around with inheritance a lot.
     
    Last edited: Feb 28, 2016
  2. Qianweijia

    Qianweijia Well-Known Member

    Joined:
    Jan 15, 2016
    Messages:
    165
    Likes Received:
    144
    Reading List:
    Link
    Preach brother. Lay thy frustrations on me and be at ease.
     
    prongsjiisan and CDLevit like this.
  3. EienMugetsuTensho

    EienMugetsuTensho [Avid Reader] [C#, C++, Python Programmer]

    Joined:
    Nov 9, 2015
    Messages:
    951
    Likes Received:
    782
    Reading List:
    Link
    c++ is a powerful tool when you know how to use it properly. I use c++ for low level stuff that needs performance (games) and c# if I wana do something easy.
     
  4. LNFanatic

    LNFanatic Programmer, Meme Farmer

    Joined:
    Oct 20, 2015
    Messages:
    150
    Likes Received:
    111
    Reading List:
    Link
    I made the horrible mistake of trying to learn c++ as my first language. I switched to Python, then went c# and suddenly, c++ wasn't so hard anymore. As long as you can understand the concepts of a c-variant language like objective-c/c#, c++ becomes many times easier. It's all about the typing. Good luck.
     
  5. maskedcerf

    maskedcerf DCLXVI

    Joined:
    Oct 22, 2015
    Messages:
    1,770
    Likes Received:
    2,329
    Reading List:
    Link
    good luck guy ^^
     
  6. Arcturus

    Arcturus Cat, Hidden Sith Lord

    Joined:
    Jan 1, 2016
    Messages:
    9,273
    Likes Received:
    17,815
    Reading List:
    Link
    I learned Javascript, then Java, then python, then C++, probably gonna learn C# next. Though learning new languages isn't too difficult, once you've learned one or two.
     
    marine1corps and Nimbus like this.
  7. Estarossa

    Estarossa 《Master of Dessert》°Resurrected Ghoul°

    Joined:
    Nov 10, 2015
    Messages:
    2,787
    Likes Received:
    3,237
    Reading List:
    Link
    I learned english
     
  8. Scarecrow

    Scarecrow > dev/null

    Joined:
    Oct 22, 2015
    Messages:
    1,919
    Likes Received:
    1,860
    Reading List:
    Link
    If it works, it works.
     
  9. Faw

    Faw Well-Known Member

    Joined:
    Jan 3, 2016
    Messages:
    165
    Likes Received:
    69
    Reading List:
    Link
    The best first language is and will always be Pascal. Teaches good programming habits since it forces you to be organized. Java/C# maybe second but they have no pointers. C/C++ as first language is really really bad.

    Python sucks.
     
    Nimbus likes this.
  10. Arcturus

    Arcturus Cat, Hidden Sith Lord

    Joined:
    Jan 1, 2016
    Messages:
    9,273
    Likes Received:
    17,815
    Reading List:
    Link
    Javascript is also terrible. I learned so many bad habits from it. Thankfully Java forced me to become a better programmer
     
  11. Scarecrow

    Scarecrow > dev/null

    Joined:
    Oct 22, 2015
    Messages:
    1,919
    Likes Received:
    1,860
    Reading List:
    Link
    Why the hate on Python m8? You don't like a,b = b,a?
     
  12. Faw

    Faw Well-Known Member

    Joined:
    Jan 3, 2016
    Messages:
    165
    Likes Received:
    69
    Reading List:
    Link
    Any language that depends on indentation to define blocks should die.
     
    Arcturus and Nimbus like this.
  13. Arcturus

    Arcturus Cat, Hidden Sith Lord

    Joined:
    Jan 1, 2016
    Messages:
    9,273
    Likes Received:
    17,815
    Reading List:
    Link
    This. really this. It's nice sometimes for little projects, but thats about it.
     
  14. Nimbus

    Nimbus Vagantem Numen, Lord of Riddles

    Joined:
    Jan 5, 2016
    Messages:
    223
    Likes Received:
    4,445
    Reading List:
    Link
    Wherefore didst thee touch JavaScript first then? 'Twas extremely ugly (used to be).
     
  15. Arcturus

    Arcturus Cat, Hidden Sith Lord

    Joined:
    Jan 1, 2016
    Messages:
    9,273
    Likes Received:
    17,815
    Reading List:
    Link
    I just picked it up randomly through a few lessons at Code Academey and a few other projects. I didn't realize just how bad it was til it was too late. That was my freshman year of HS though, so I didn't know any better.
     
    Nimbus likes this.
  16. Nimbus

    Nimbus Vagantem Numen, Lord of Riddles

    Joined:
    Jan 5, 2016
    Messages:
    223
    Likes Received:
    4,445
    Reading List:
    Link
    Condolences. 'Tis better now, so that counteth for something.
    This One avoided't like plague after seeing't used on websites.
     
  17. Faw

    Faw Well-Known Member

    Joined:
    Jan 3, 2016
    Messages:
    165
    Likes Received:
    69
    Reading List:
    Link
    No. Not even for little projects. For the love of god dont use it. Let it fade into obscurity like RPG and BASIC.
     
    Nimbus likes this.
  18. Nimbus

    Nimbus Vagantem Numen, Lord of Riddles

    Joined:
    Jan 5, 2016
    Messages:
    223
    Likes Received:
    4,445
    Reading List:
    Link
    That seemeth extremely unlikely, considering all the support 'tgets.
     
  19. Scarecrow

    Scarecrow > dev/null

    Joined:
    Oct 22, 2015
    Messages:
    1,919
    Likes Received:
    1,860
    Reading List:
    Link
    It's probably impossible. If I remember correctly it's one of the top choices for data scientist. Maybe even more popular than R?
     
    Cantelope likes this.
  20. Arcturus

    Arcturus Cat, Hidden Sith Lord

    Joined:
    Jan 1, 2016
    Messages:
    9,273
    Likes Received:
    17,815
    Reading List:
    Link
    All of my science professors like it.
     
    Cantelope likes this.
Thread Status:
Not open for further replies.