constant defined using connst int and #define

Discussion in 'Software' started by prati, Oct 27, 2012.

  1. prati

    prati

    Joined:
    Aug 2, 2012
    Messages:
    1
    Likes Received:
    0
    Suppose i have defined a constant as const int MAX =5 and i am using it in a function called find().


    void find()
    {

    if(MAX==5)
    {
    //do this
    }
    else
    {
    //do this
    }
    }

    if i am calling this function for 100 of times then which way is better to define a constant as i can define a constant in 2 ways.
    1 const int MAX=5
    2.#define MAX 5
     
    prati, Oct 27, 2012
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.