Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Administrator Privileges Pin
MsmVc13-Sep-10 20:25
MsmVc13-Sep-10 20:25 
GeneralRe: Administrator Privileges Pin
Eugen Podsypalnikov13-Sep-10 20:26
Eugen Podsypalnikov13-Sep-10 20:26 
QuestionHow can find 2nd sat of month? Pin
Le@rner13-Sep-10 19:37
Le@rner13-Sep-10 19:37 
AnswerRe: How can find 2nd sat of month? Pin
Eugen Podsypalnikov13-Sep-10 20:11
Eugen Podsypalnikov13-Sep-10 20:11 
GeneralRe: How can find 2nd sat of month? Pin
CPallini13-Sep-10 22:59
mveCPallini13-Sep-10 22:59 
GeneralRe: How can find 2nd sat of month? Pin
Eugen Podsypalnikov13-Sep-10 23:23
Eugen Podsypalnikov13-Sep-10 23:23 
AnswerRe: How can find 2nd sat of month? PinPopular
CPallini13-Sep-10 22:58
mveCPallini13-Sep-10 22:58 
QuestionPointer Pointing to Itself? Pin
Skippums13-Sep-10 14:45
Skippums13-Sep-10 14:45 
I have a class that acts something like the following:
class Foo {
private:
    int const (&InitPrimes() const)[3] {
        int (*const rval)[3] = new int[1][3];
        (*rval)[0] = 2;
        (*rval)[1] = 3;
        (*rval)[2] = 5;
        return *rval;
    }

public:
    int const (&primes)[3];

    explicit Foo() : primes(InitPrimes()) { }
    virtual ~Foo() { delete[] ℙ }
};
If I have the following code in a main function, all three of the cout statements print the same value:
Foo a;
cout <<  a.primes    << endl;
cout << &a.primes[0] << endl;
cout << &a.primes    << endl;
How is this possible? It seems logical that "a.primes" == "&a.primes[0]", but shouldn't "&a.primes" be a distinct value? If they are the same, then shouldn't the following contradiction be true (assume all three return value 0xF0):
Address 0xF0 (&a.primes   ) is of type "(int*)[3]" and holds the value 0xF0, the location of a.primes
Address 0xF0 ( a.primes   ) is of type " int  [3]" and holds the value 0xF0, the address of the first element in the array
Address 0xF0 ( a.primes[0]) is of type " int     " and holds the value    2, the first prime number
Clearly I am misinterpreting which of these assumptions is false, because I know that address 0xF0 can't be 0xF0 and 2 at the same time (let's not get into a discussion on simultaneity with respect to relativity). If I type
*((int*)0xF0)
into the immediate window (VS 2008), it returns 2, but then why is &a.primes == 0xF0? Any clarification on why the above is happening would be greatly appreciated. Thanks,
Sounds like somebody's got a case of the Mondays

-Jeff

AnswerRe: Pointer Pointing to Itself? Pin
Peter_in_278013-Sep-10 19:13
professionalPeter_in_278013-Sep-10 19:13 
AnswerRe: Pointer Pointing to Itself? Pin
Aescleal13-Sep-10 23:30
Aescleal13-Sep-10 23:30 
GeneralRe: Pointer Pointing to Itself? Pin
Skippums14-Sep-10 3:46
Skippums14-Sep-10 3:46 
GeneralRe: Pointer Pointing to Itself? Pin
Aescleal14-Sep-10 3:57
Aescleal14-Sep-10 3:57 
QuestionSending HTTP Post via TCP/IP Pin
Dustin Henry13-Sep-10 11:15
Dustin Henry13-Sep-10 11:15 
AnswerRe: Sending HTTP Post via TCP/IP Pin
Dustin Henry13-Sep-10 11:37
Dustin Henry13-Sep-10 11:37 
GeneralRe: Sending HTTP Post via TCP/IP Pin
Moak14-Sep-10 0:32
Moak14-Sep-10 0:32 
AnswerRe: Sending HTTP Post via TCP/IP Pin
markkuk13-Sep-10 11:52
markkuk13-Sep-10 11:52 
GeneralRe: Sending HTTP Post via TCP/IP Pin
Dustin Henry13-Sep-10 12:15
Dustin Henry13-Sep-10 12:15 
AnswerRe: Sending HTTP Post via TCP/IP Pin
Moak14-Sep-10 0:22
Moak14-Sep-10 0:22 
GeneralRe: Sending HTTP Post via TCP/IP Pin
Dustin Henry14-Sep-10 7:02
Dustin Henry14-Sep-10 7:02 
QuestionValidating console input Pin
Danzy8313-Sep-10 7:33
Danzy8313-Sep-10 7:33 
AnswerRe: Validating console input Pin
mk1488213-Sep-10 9:08
mk1488213-Sep-10 9:08 
AnswerRe: Validating console input Pin
Aescleal13-Sep-10 11:10
Aescleal13-Sep-10 11:10 
Questiondelete option in IE8 address bar Pin
inza113-Sep-10 7:04
inza113-Sep-10 7:04 
Answersomeone?any idea? Pin
inza122-Sep-10 4:50
inza122-Sep-10 4:50 
QuestionCalling APIs Problem In Drivers Pin
Coder-12345613-Sep-10 7:00
Coder-12345613-Sep-10 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.