Thread: Words i cant get the meaning

  1. #1
    Dragoon Lover wyvern's Avatar
    Join Date
    Jul 2005
    Location
    dragooncity
    Posts
    28

    Words i cant get the meaning

    i came across with this few var declaration words i dont know what they do please explain me plz:

    - Unsigned ( ex: unsigned int variable)

    - Const ( ex: Const char variable )

    - long ( ex: long int variable)

    ....


    if anyone know what this mean please help me

    Regards: Wyvern.

    Ps: My Dragoons say "hi" to everyone.

  2. #2
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    A long int uses at least as much memory as an int. Usually, but not always, they both use 32 bits.

    Every integer gets represented by a certain amount of bits. With an unsigned integer datatype, all combinations of the bits represent a positive number, whereas a signed integer uses about half the combinations to represent negative numbers.

    A const variable cannot be altered.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    Here's a list of C++ Keywords.

  4. #4
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    Quote Originally Posted by Rashakil Fol
    A const variable.
    oxymoron?

    a combination of two terms with exact opposite meanings.



    I know we have to declare constants, and assign values, but they aren't really variables, the declaration is just a simpler way to make use of the value. ( like pi, try typing pi every time you need to use the value, declaring a constant and assigning the value is much simpler. )
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Actually depending on the exact situation a const can be variable.

    unsigned is a modifier that means that the value is positive only (no negative sign). This helps extend the upper limit for integer values.

    long is a modifier that basically says to use another set of min ranges for integer values. Depending on the compiler this can have no affect.

    const is a modifier that means you can't change the value of the variable. Now this isn't 100% because you can cast away the const and change the value under certain conditions.

    Now the reason I said a const variable is because of this:
    Code:
    #include <iostream>
    
    using namespace std;
    
    void func(const int &x)
    {
            int &y = const_cast<int&>(x);
            y = x + 5;
    }
    
    int main()
    {
            int i;
            cin >> i;
            cout<<"Before: "<<i<<'\t';
            func(i);
            cout<<"After: "<<i<<endl;
    }

  6. #6
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    which can be usefull in avoiding mistakenly altering the value.
    but is not the idea behind a constant to reduce the chances of keyboard errors in large values, such as pi, or a 18+ digit number?

    anything you setup in your code you can change, including constants. I just think that declaring it a constant if you are going to be altering the value is wasted effort.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well it also depends on how you define variables in programming. I think the majority defines it as a named location in memory that has a value. So saying const variable is perfectly legal since using the const keyword still creates a variable.

    Now const itself has no idea, its a thing. My chair is a thing, it does not create ideas. I can use my chair to implement an idea of mine (say sitting on my butt)

    anything you setup in your code you can change, including constants.
    First rule: Don't make absolute statements like that.

  8. #8
    Dragoon Lover wyvern's Avatar
    Join Date
    Jul 2005
    Location
    dragooncity
    Posts
    28
    THANK U

    the confusy part is not clear as water.

    <3.E>

    Quote Originally Posted by Thantos
    Actually depending on the exact situation a const can be variable.

    unsigned is a modifier that means that the value is positive only (no negative sign). This helps extend the upper limit for integer values.

    long is a modifier that basically says to use another set of min ranges for integer values. Depending on the compiler this can have no affect.

    const is a modifier that means you can't change the value of the variable. Now this isn't 100% because you can cast away the const and change the value under certain conditions.

    Now the reason I said a const variable is because of this:
    Code:
    #include <iostream>
    
    using namespace std;
    
    void func(const int &x)
    {
            int &y = const_cast<int&>(x);
            y = x + 5;
    }
    
    int main()
    {
            int i;
            cin >> i;
            cout<<"Before: "<<i<<'\t';
            func(i);
            cout<<"After: "<<i<<endl;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 10:01 AM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM