Results 1 to 9 of 9

Thread: Dynamic array in a struct?

  1. #1

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294

    Question Dynamic array in a struct?

    Is it possible?

  2. #2

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294

    Second question

    Is there any Real data type? I read it here.

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Code:
    Data Type Ranges
    C/C++ recognizes the types shown in the table below.
    
    Type Name Bytes Other Names Range of Values 
    int * signed, 
    signed int System dependent 
    unsigned int * unsigned System dependent 
    __int8 1 char, 
    signed char –128 to 127 
    __int16 2 short, 
    short int, 
    signed short int –32,768 to 32,767 
    __int32 4 signed, 
    signed int –2,147,483,648 to 2,147,483,647 
    __int64 8 none –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 
    char 1 signed char –128 to 127 
    unsigned char 1 none 0 to 255 
    short 2 short int, 
    signed short int –32,768 to 32,767 
    unsigned short 2 unsigned short int 0 to 65,535 
    long 4 long int, 
    signed long int –2,147,483,648 to 2,147,483,647 
    unsigned long 4 unsigned long int 0 to 4,294,967,295 
    enum * none Same as int 
    float 4 none 3.4E +/- 38 (7 digits) 
    double 8 none 1.7E +/- 308 (15 digits) 
    long double 10 none 1.2E +/- 4932 (19 digits)
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294

    Vlatko...

    I didn't ask for a complete list of all data types. In this case a simple yes or no would be enough.

    As for the first question...?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Real is a misnomer -- integers are real numbers as well Float is correct because the decimal point "floats" around the number depending on the exponent.
    Code:
    struct mystruct {
        int *piArray;
    };
    
    void somecode() {
        mystruct xx;
        x.piArray = new int[50];
        delete[] x.piArray;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294

    Smile My apologies Vlatko

    You're right. The thing is that I was considering more irrational numbers which are real too. I should have mentioned it.

    Finally I see a practic use of pointers! I'm following the cplusplus tutorial which talks about many things, but it's kinda difficult to me to see how can I use them. In time I'll see it perhaps.

    One of those things is a class. I see it like a way of organizing our code better. Am I wrong? I was watching this interesting thread started by kedaman. He mentions the use of classes to solve the problem. In which way can it be good to use a class? (in general, not only in this particular case)

    http://161.58.186.97/showthread.php?...ational+number

  7. #7

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294

    ....ok

    Found a good example that shows to me a good use of classes (just closing topic).
    If anyone is interested:Polynomial Class

    Later


  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Didn't someone post that quite a while ago?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Banned
    Join Date
    Feb 2001
    Location
    Back to sh*tland
    Posts
    294
    Yep,

    Hurray for search feature!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width