Thread: A few questions...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    6

    A few questions...

    Ya, I'm a newbie, and am learning C++ from online tutorials...so, can ya help me out?

    1. Do prototypes for functions always have to be in between your header files and the int main function?

    2. Does a++ always add 1 to the variable a? How can I add more than just one to a?

    3. What do OpenGL and DirectX do exactly? are they software, plug-ins, or downloads? Which do you recommend I use, or is there some better one that I don't know about?

    4. Could someone give me a definition of the word "argument"?
    Last edited by Milla Time; 08-06-2002 at 05:43 PM.

  2. #2
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    IOts milla time. jokingly!

    1. Do prototypes for functions always have to be in between your header files and the int main function?
    No!

    2. Does a++ always add 1 to the variable a? How can I add more than just one to a?
    it can be written also a+1. To add more just a+2...

    3. What do OpenGL and DirectX do exactly? are they software, plug-ins, or downloads? Which do you recommend I use, or is there some better one that I don't know about?
    I dont know, try www.howstuffworks.com. Its a great reference i use sometimes.

    4. Could someone give me a definition of the word "argument"?
    Its the value of the argument corresponding to a formal parameter used within the body of the executing function of a function call.


    Last edited by correlcj; 08-06-2002 at 06:12 PM.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    1) No. You can place the function body in a header file and call it from there...

    2)In C, yes. In C++, you can overload it.

    3)OpenGl and similar are precompiled libraries of functions which can be called from your program if linked properly.

    4)Argument = Parameter.

    int foo( int a, int b ); //<--'a' and 'b' are arguments to the foo func.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Shadow12345
    Guest
    Hi there. If you want to add more than 1 to the variable a you could use
    a += 5;
    This is the same as saying
    a = a + 5;


    OpenGL is an API (Application Programming Interface) for doing graphics, especially games. Basically you include the opengl header files, and then you link the opengl libraries, and once you have done that you can write graphics programs. It takes quite a while to learn how to use all of the functions in the opengl libraries (there are altogether several hundred functions that make up OpenGL). I don't know how in depth you wanted to get on this topic, but DirectX is the name given for several libraries, the X is actually a variable ( I dont' know if you knew that or not).
    The libraries for DirectX are:
    DirectDraw/Direct3d (the graphics parts of DirectX)
    DirectSound/DirectMusic (the sound parts of DirectX)
    DirectInput (used for special features on game controllers, i.e force feedback for joysticks in fighter pilot games)
    DirectPlay(the networking portion of DirectX...used for multiplayer games across LANs and the Internet)
    DirectShow(used for playing video files such as AVIs and MPGs)
    DirectSetup(Helps installing directx features)

    DirectX is available only for the Windows operating systems, but includes not just a graphics libraries, but also all of those other ones. OpenGL is available for almost any operating system, but is only a graphics library and must use other libraries to achieve all the rest of the functionality required.
    Ok, I'll shut up now...I really hope I helped somewhat.

  5. #5
    Unregistered
    Guest
    as long as the function prototype is seen by the compiler before the first call to that function you're home free. Traditionally the prototypes are located where you suggest or in header files however. They can be anywhere in the program however.

    The += must be overloaded for the variable type you are trying to use it with in order for it to work. It works fine for all the primitive variables, including char, since it comes already overloaded for you, but it may not do what you think it does with type char so if used in that context be forewarned.

    functions manipulate data. One place functions can get data is from local variables. Another is from global variables. The third is to be passed data from the calling function. By definition the calling function must pass a variable of some type to the called function. the variable types that need to be passed to a given function are called parameters when they are listed in the function prototype/definition and arguments when you actually pass them during the function call, or maybe it's the other way way around. unless you are working in some rarefied environment however it doesn't make a lot of difference which term you use. Note that void is a valid variable type meaning no actual data is being passed, and if the () following the function name is empty a variable of type void is implied.

  6. #6
    Registered User
    Join Date
    Jun 2002
    Posts
    106
    openGL is a graphics liblary it used to crate the graphics you see in the games it used with c++,c or some other programming language that opengl supports

    int example(int argument);
    argument is a argument

    you can try overload operators to ad more
    C++ Makes you Feel Better

    "Gravity connot be held reponsible for people falling in love"--Albert Einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM