Page 5 of 5 FirstFirst ... 3 4 5
Results 81 to 95 of 95

Thread: C++ question im confused     submit to reddit submit to twitter

  1. #81
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    Quote Originally Posted by Eanae
    stdafx.h... this is the general header file in which all #include statements should go.
    Err.. No. You've been trained to think that because you've been doing a lot of visual c++ programming. Even in Visual C++, you shouldn't "put all #include statements into" stdafx.h. It's specifically for precompiled headers, and you should carefully select which #includes you put in stdafx.h

  2. #82
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    Quote Originally Posted by LinktheDeme
    double HeatIndex(double t, double r)
    {
    return (-42.379 + 2.04901523 * t + 10.14333127 * r
    -0.22475541 * t * r - (6.83783 * -1000) * pow(t, 2)
    -(5.48171 * -100) * pow(r, 2) + (1.22874 * -1000) * pow(t, 2) * r
    +(8.5282 * -10000) * t * pow(r, 2) - (1.99 *-1000000) * pow(t, 2) * pow(r, 2));
    }
    I know you still haven't learned a lot yet, but I would count off for this because of how absolutely horrible this is to read. I'm sure you can figure out how to make it look nicer.

  3. #83
    Nidhogg
    Join Date
    Jul 2006
    Posts
    3,999
    BG Level
    7

    Quote Originally Posted by divisortheory
    Quote Originally Posted by Eanae
    stdafx.h... this is the general header file in which all #include statements should go.
    Err.. No. You've been trained to think that because you've been doing a lot of visual c++ programming. Even in Visual C++, you shouldn't "put all #include statements into" stdafx.h. It's specifically for precompiled headers, and you should carefully select which #includes you put in stdafx.h
    Did you wake up to check on me? :D thanks alot for your help btw and to everyone else

  4. #84
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    No, I'm trying to fix a bug in DvsParse before I go to bed so I can release a new version soon, but its pissing me off

    BTW
    edit: #2 was error because i forgot E in it i guess it does understand Exponents as E?
    Figure out ways to answer this type of question for yourself. If you write some code that says "10E3" and it fails to compile, chances are it doesn't understand it. If it does compile, it understands it. Conceptual questions you may need help with, but simple stuff like this there's no excuse for not being able to answer on your own. If it compiles but you're not sure if it's what you expect it is, write the following code:

    int main()
    {
    int X = 10E3;
    cout << X;
    }

    Then see what gets printed.

    If it doesn't compile, try this:

    int main()
    {
    int X = 103;
    cout << X;
    }

    If that does compile but the first one doesn't, it's a pretty safe bet that it doesn't allow scientific notation.

  5. #85
    VZX
    VZX is offline
    Relic Shield
    Join Date
    Dec 2006
    Posts
    1,700
    BG Level
    6
    FFXI Server
    Asura

    On other side, I just finished building my meshviewer.
    550~ lines of code w/o proper functions placement drive me nuts

    still buggy though I hate it so much
    gotta do the data structure

    gonna be late... o well

  6. #86
    Black Belt
    Join Date
    Aug 2005
    Posts
    5,907
    BG Level
    8
    FFXI Server
    Quetzalcoatl

    You should really learn how to make your compilation look nicer, as well as learn include comments <.<;

    It really helps yourself and your teacher. Hell, when I took C++, my teacher didn't even give us grades if we didn't include comments.

  7. #87
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    Re: C++ question im confused

    Quote Originally Posted by VZX
    Quote Originally Posted by Taj
    Quote Originally Posted by Devek
    Technically OO languages like C++ and Java don't have functions
    No. Functions are part of the C++ Standard.
    you can clearly see Java doesn't really have a function. It's a more pure-OO programming language

    you still can see some functions in C++ because they are extended OO version of C. At least that's what I learned from using C++ for 5/6 semesters
    Using cout instead of printf in C code does not magically make your code C++

    It is about the right tool for the job.. C++ has a role. If thats best you can write is some procedural code disguised as C++ you're really going to be fucked when you get a job somewhere and they turn to you and show you a factory(do they even teach pattens in college?) designed in Together and ask you to implement it.

    I guess technically this is an argument I could never win because I suppose if a c++ compiler accepts it, it is c++ code.

    If you already mastered C it will take you 5 min to learn how to get stuff to compile in C++. The hard work doesn't involve writing any code at all, it is training yourself to think properly and the first thing that needs to go is global variables and functions.

    Or you can just be another example of why college is worthless..

  8. #88
    VZX
    VZX is offline
    Relic Shield
    Join Date
    Dec 2006
    Posts
    1,700
    BG Level
    6
    FFXI Server
    Asura

    Re: C++ question im confused

    Quote Originally Posted by Devek
    Using cout instead of printf in C code does not magically make your code C++

    It is about the right tool for the job.. C++ has a role. If thats best you can write is some procedural code disguised as C++ you're really going to be fucked when you get a job somewhere and they turn to you and show you a factory(do they even teach pattens in college?) designed in Together and ask you to implement it.

    I guess technically this is an argument I could never win because I suppose if a c++ compiler accepts it, it is c++ code.

    If you already mastered C it will take you 5 min to learn how to get stuff to compile in C++. The hard work doesn't involve writing any code at all, it is training yourself to think properly and the first thing that needs to go is global variables and functions.

    Or you can just be another example of why college is worthless..
    Are you quoting me or someone else's in nested quote?

  9. #89
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    I was quoting you while responding to people who think procedural c++ is cool.

    Not quite awake yet, I should of better defined who I was talking to.. oh well.

  10. #90
    VZX
    VZX is offline
    Relic Shield
    Join Date
    Dec 2006
    Posts
    1,700
    BG Level
    6
    FFXI Server
    Asura

    well there was a rough time when I learn to code something fully in an OO-manner.
    For example... if I want to make a function that does an "open file" function. That function should not necessarily be a method of an object/instance, you can just make a simple function without being bound by any objects/instances and can be used everywhere.
    In java, you must force yourself to create a dummy object, and have the function implemented as static function (IIRC.. didn't touch java for almost 2 yrs now)

    CMIIW

  11. #91
    Nidhogg
    Join Date
    Mar 2006
    Posts
    3,954
    BG Level
    7

    About damn time we had a C++ thread here.

  12. #92
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    Quote Originally Posted by VZX
    well there was a rough time when I learn to code something fully in an OO-manner.
    For example... if I want to make a function that does an "open file" function. That function should not necessarily be a method of an object/instance, you can just make a simple function without being bound by any objects/instances and can be used everywhere.
    In java, you must force yourself to create a dummy object, and have the function implemented as static function (IIRC.. didn't touch java for almost 2 yrs now)

    CMIIW
    You're right.. you shouldn't create an object to open a file.

    You're not thinking OOish though.

    The file IS an object. One of the methods of the object might be a way to open it. You never just open a file, you often do something with it afterwards like read it. It is beautiful because you can hide all the ugly details of reading that file in one place.

    If you find yourself trying to cruft "dummy" objects and stuff together it is because your approach is wrong. Forcing procedural logic on OO is bad and vice versa, use the right tool for the job, etc.

  13. #93
    Yoshi P
    Join Date
    Jul 2005
    Posts
    5,016
    BG Level
    8

    Re: C++ question im confused

    Quote Originally Posted by Devek
    I guess technically this is an argument I could never win because I suppose if a c++ compiler accepts it, it is c++ code.
    Actually i would argue that if it's part of the C++ standard, it's C++ code, and hence a C++ compiler should accept it. Functions are part of the C++ standard, hence they are C++ code.

    OTOH, a C++ compiler can accept whatever it wants, including its own language extensions. The fact that it accepts it doesn't make it C++ code.

    I think you're underestimating the design and goals of the language. Global functions are just as much C++ as virtual base classes. Are they as "object oriented" as virtual base classes? Probably not. But like I said in an earlier post, C++ was never intended to be a purely object oriented language.

  14. #94
    Black Belt
    Join Date
    Aug 2005
    Posts
    5,907
    BG Level
    8
    FFXI Server
    Quetzalcoatl

    should go assembly. So much faster <.<;

    Although I suppose it depends on what you're doing... most everythings can be coded in c++, but if you need something that repeats itself often throughout the entire code, coding that in assembly is much better.

  15. #95
    Nikkei's Hoe
    Worse than her at uno

    Join Date
    Dec 2006
    Posts
    6,236
    BG Level
    8
    FFXIV Character
    Eanae Hikari
    FFXIV Server
    Gilgamesh
    FFXI Server
    Cerberus
    WoW Realm
    Hyjal

    Quote Originally Posted by divisortheory
    Quote Originally Posted by Eanae
    stdafx.h... this is the general header file in which all #include statements should go.
    Err.. No. You've been trained to think that because you've been doing a lot of visual c++ programming. Even in Visual C++, you shouldn't "put all #include statements into" stdafx.h. It's specifically for precompiled headers, and you should carefully select which #includes you put in stdafx.h
    So I see. Guess it's been drilled into my head too much. 8)

Page 5 of 5 FirstFirst ... 3 4 5

Similar Threads

  1. a tech question because im a noob
    By Medivac in forum General Discussion
    Replies: 11
    Last Post: 2006-09-21, 23:57
  2. Just got a question for you guys
    By Blackwar in forum General Discussion
    Replies: 3
    Last Post: 2004-08-06, 20:14
  3. psst.. im at work...
    By Judah in forum General Discussion
    Replies: 6
    Last Post: 2004-07-19, 14:47